|
Hello everyone,
Is there anyone that I can know there was a Mouse Double Click in the MainForm_MouseDown? I currently can detect if there has been a Left or a Right click but I would like to be able to check for Double Click.
if (e.Button == MouseButtons.Left)<br />
{<br />
MessageBox.Show("You have just clicked on " + e.Button + " button.");<br />
MessageBox.Show("X: " + e.X + " -- Y: " + e.Y); <br />
}<br />
if (e.Button == MouseButtons.Right)<br />
{<br />
MessageBox.Show("You have just clicked on " + e.Button + " button.");<br />
MessageBox.Show("X: " + e.X + " -- Y: " + e.Y);<br />
}
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
Hello,
I don't think that it's possible in MouseDown, as MouseDown is fired bevore Click and Double Click.
But MouseUp is fired after Click and DoubleClick.
So this would work:
private bool FlagDoubleClick = false;
protected override void OnDoubleClick(EventArgs e)
{
FlagDoubleClick = true;
base.OnDoubleClick (e);
}
protected override void OnMouseUp(MouseEventArgs e)
{
if(FlagDoubleClick)
{
FlagDoubleClick= false;
}
base.OnMouseUp (e);
}
All the best,
Martin
|
|
|
|
|
Hi,
MouseDown event offers MouseDownEventArgs parameter
its Clicks member contains what you need:
on a double click, the event fires twice, once with Clicks=1, once Clicks=2
|
|
|
|
|
Hello Luc,
I just tested it and saw that it works.
But I don't understand why.
When is the Clicks property reseted?
And isn't a Click only a Click if the MouseUp is excecuted?
I'm sure you will clear my confusion!
Thanks for your time!
-- modified at 5:56 Monday 30th July, 2007
Just did additional tests, and now I think I understand it.
Looks like the DoubleClick is fired only by the correct MouseDown delta time, no second MouseUp needed for the validation.
But it get's fired only after MouseUp is excecuted.
I'm not sure if this behaviour is very logic, but who said that programming has to be logic at all!
All the best,
Martin
|
|
|
|
|
Hi Martin,
Martin# wrote: I just tested it and saw that it works
A click consists of a down followed by an up (both keyboard and mouse)
To count clicks, you could wait until you get a click, then increment counter;
or you could simply count physical downs (cant have two physcial downs without an
up in beteen !)
So you may argue that the member name should have been Count instead of Clicks,
but it is no miracle they can make it work.
And you would be right if you don't like MSDN saying "MouseEventArgs.Clicks gets
the number of times the mouse button was pressed and released"
|
|
|
|
|
Hello Luc,
Luc Pattyn wrote: So you may argue that the member name should have been Count instead of Clicks
Would be better!
Specially when you see a scenario, where you:
Make the double MouseDown fast enough for the DoubleClick (so in MouseDown, you get e.Clicks == 2), and then Move the Mouse over an other Control bevor you release the Mouse.
In this case you would assume the DoubleClick is comming because of MouseDown, but it will never get fired.
All the best,
Martin
|
|
|
|
|
Martin# wrote: then Move the Mouse over an other Control
that is why one should use KeyPress and MouseClicked as much as possible,
and only use KeyDown and MouseDown if something really needs to be done
as soon as the user's action starts.
|
|
|
|
|
Hello,
I'm trying to make an application so that I can display an XML document such that it doesnt show the text in the tag names of the XML document. It should show the text in those tags rather than tag names. e,g
<my_tag>This is my Tag
Then it should display 'This is my tag' instead of my_tag. Please tell me how I can do that. The problem is further increased as I want to provide some filtering capability on the basis of this text prior to populating the treeView.
Any help would be highly appreciated.
Thanks
Rocky
|
|
|
|
|
|
I want to develop an input method (using visual studio 2005 and c#) for my mother_language .
(when inputing a character it will lists the words which begin with the character).
anybody can tell me what should I do? please help me!
Ak Hon From the Middle Asia
|
|
|
|
|
I believe that it's possible to build a list of words and set them up to offer auto complete, either in a textbox, or a list box ( not sure of hte details ). If not, you need a list of words, and you need to show a filtered list as someone types.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Ak Hon wrote: when inputing a character it will lists the words which begin with the character
Sounds like you are trying to implement some sort of auto-complete? Correct me, if I am wrong
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I am not sure this is a great idea.
Unless your native language has a lot of characters, there may be hundreds or
even thousands of words starting with the same character, so showing all these
in a list will take quite some time, and may not be appreciated by the user at all...
|
|
|
|
|
hi..
currently i am doing a project using c# express edition,
but i dont know how to do its sqlclr connection and how to deploy it.
could anybody help me on this?
thanks,
jac
|
|
|
|
|
Do you mean how to create connection to sql server or what?
If you want to create connection to sql server 2005 Express :
Step 1:
In you app.config add this code
<connectionStrings>
<add name="CONNECT"
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=YourDatabase;Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>
Step 2:
add reference to your main code
using System.Data;
using System.Data.SqlClient;
add this to your main code
string connectionString;
connectionString = ConfigurationManager.ConnectionStrings["CONNECT"].ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
then if you want to open connection to your database :
conn.Open();
if you want to close connection :
conn.Close();
Hope this will help you.
Regard,
Edwin
|
|
|
|
|
Actually, the connection string i have done it but still i have problem.
let me explain what exactly happen in my application..
- my system is created in the c# express edition and for database is sql server 2005 (express edition)
- the system is in console application...
The idea is like these:
- supposed that my system can retrieve the result that fired by the trigger everytime there is a data inserted. Means that, everytime a data inserted into the table, all the data details would be display on the console application
- for now i have created the trigger but i dont know how to display the result fired by trigger on the console application.
If u can help me or give me idea on this, it would be very helpful.
Thanks in advance
Jac
|
|
|
|
|
Oh... Console base application...
Usually I create Windows app. To show my data, I usually use Datagridview.
If I want everytime a data inserted into the table, I just refresh the Datagridview's data source, and it will show the inserted data.
In your case, if you show your data using dataset or xml you just need to declare your data source again... I think it will auto refresh.
regard,
Edwin
|
|
|
|
|
hem...so do u mean that i dont need the trigger function?...because i dont have any other way to get the real time data inserted in the database since the trigger function fired whenever any transaction made on that particular table.
Before, i have done same thing that only using the dataset but if using the dataset i cant get the latest data (real time) inserted.
regard
Jac
|
|
|
|
|
No... no... no..., I mean that u just declare your data source again that u use to show your data, then the data that u showed before will auto refresh. There is no problem if u use trigger or other function. This code below just for example.
e.g :
I have a class1 to show my data from table like this :
private List<ContactBusiness> m_Contacts;
MyGridView.DataSource = m_Contacts;
Then in class2 to insert data:
private List<ContactBusiness> m_Contacts;
InsertData();
MyGridView.DataSource = m_Contacts;
Regard,
Edwin
|
|
|
|
|
oic...i have done the dataset but now the error is unhandled InvalidOperationException
the error description is:-> The requested operation requires a SqlClr context, which is only available when running in the Sql Server process.
I dont know how to use the SqlClr context how to write it in my code
jac
|
|
|
|
|
Can I see your code??
Regard,
Edwin
|
|
|
|
|
At first I do like This
=> using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Microsoft.CSharp;
using Microsoft.SqlServer.Server;
using System.Data;
using System.Data.SqlClient;
namespace AITania
{
class Program
{
//public static void InsertTrigger()
//{
// SqlTriggerContext triggerContext = SqlContext.GetTriggerContext();
// SqlPipe sqlPipe = SqlContext.GetPipe();
// SqlCommand command = SqlContext.GetCommand();
// if (triggerContext.TriggerAction == System.Data.Sql.TriggerAction.Insert)
// {
// command.CommandText = "SELECT * FROM INSERTED";
// sqlPipe.Execute(command);
// }
//}
static void Main(string[] args)
{
//---------------------------Database connection
SqlConnection conn = new SqlConnection("Data Source=DIMENSION3000\\SQLEXPRESS; Initial Catalog=AITania; User Id=sa; Password=123456");
DataSet AlertDataSet = new DataSet();
SqlDataAdapter da;
SqlCommandBuilder cmdBuilder;
//--------------------------Open Connection
conn.Open();
da = new SqlDataAdapter("SELECT * FROM AIEvent", conn);
cmdBuilder = new SqlCommandBuilder(da);
da.Fill(AlertDataSet, "AIEvent");
//-------------------------Displaying error
foreach (DataRow dr in AlertDataSet.Tables[0].Rows)
{
Console.WriteLine("EventID: {0}", dr["EventID"]);
Console.WriteLine("Time of Occur: {0}", dr["TimeOfOccur"]);
Console.WriteLine("Location: {0}", dr["LocationID"]);
Console.WriteLine("");
}
Console.ReadLine();
//--------------------------Close Connection
conn.Close();
//AIClass.AICheck.checkUserRole();
}
}
}
|
|
|
|
|
then after i have read about the trigger..I do like this (will call AIClass at the main class):
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Server;
using System.Data;
using System.Data.SqlClient;
namespace AIClass
{
public class AICheck
{
[SqlTrigger(Event = "FOR INSERT", Name = "AITrigger", Target = "AIEvent")]
public static void checkUserRole()
{
//if (!SqlContext.IsAvailable)
//{
// Console.Write("Context none");
// Console.Read();
//}
//else
//{
SqlTriggerContext tgContext = SqlContext.TriggerContext;
SqlConnection conn = new SqlConnection("Data Source=DIMENSION3000\\SQLEXPRESS; Initial Catalog=AITania; User Id=sa; Password=123456");
using ( conn = new SqlConnection("context connection=true"))
{
conn.Open();
//SqlCommand cmd = conn.CreateCommand();
SqlDataReader reader;
//cmd.ExecuteNonQuery();
string msg = "";
if (tgContext.TriggerAction == TriggerAction.Insert)
{
SqlCommand sqlComm = new SqlCommand("SELECT * FROM INSERTED",conn);
//cmd.CommandText = "SELECT * FROM INSERTED";
SqlContext.Pipe.ExecuteAndSend(sqlComm);
//reader = cmd.ExecuteReader();
//sqlComm.Connection = conn;
//sqlComm.CommandText = "SELECT * FROM INSERTED";
//for (int x = 0; x < tgContext.ColumnCount; ++x)
//{
// msg += string.Format("Column {0} {1} been updated{2}", x, (tgContext.IsUpdatedColumn(x) ? "has" : "has not"), Environment.NewLine);
//}
for (int i = 0; i < reader.FieldCount; i++)
{
msg = msg + reader.GetName(i) + ":" + (string)reader[i] + " ";
}
} conn.Close();
}
//}
}
}
}
|
|
|
|
|
Oh, IC...
Now can I see your trigger query?
Regard,
Edwin
|
|
|
|
|
this is my trigger:
CREATE TRIGGER AITrigger ON AIEvent
FOR INSERT
AS
EXTERNAL NAME [AIClass].[AIClass.AICheck].[checkUserRole]
|
|
|
|