Click here to Skip to main content
15,914,642 members
Home / Discussions / C#
   

C#

 
GeneralRelation between Tables a dataset Pin
Gedrain21-Dec-04 8:57
Gedrain21-Dec-04 8:57 
GeneralRe: Relation between Tables a dataset Pin
Heath Stewart21-Dec-04 12:51
protectorHeath Stewart21-Dec-04 12:51 
GeneralRe: Relation between Tables a dataset Pin
Gedrain21-Dec-04 23:08
Gedrain21-Dec-04 23:08 
GeneralRe: Relation between Tables a dataset Pin
Heath Stewart22-Dec-04 6:18
protectorHeath Stewart22-Dec-04 6:18 
GeneralRe: Relation between Tables a dataset Pin
Gedrain22-Dec-04 7:22
Gedrain22-Dec-04 7:22 
GeneralRe: Relation between Tables a dataset Pin
Heath Stewart22-Dec-04 9:20
protectorHeath Stewart22-Dec-04 9:20 
GeneralDoubleClick and Click Events ... Left Mouse Button Pin
new_phoenix21-Dec-04 8:49
new_phoenix21-Dec-04 8:49 
GeneralRe: DoubleClick and Click Events ... Left Mouse Button Pin
Heath Stewart21-Dec-04 13:01
protectorHeath Stewart21-Dec-04 13:01 
A double-click is defined as the left (or right, on a left-handed mouse configuration) click times 2 within a certain configurable threshold. In order to handle double-clicks you'll need to implement a Timer and use the Click event to determine if there was a double-click. To fire the event, simply call OnDoubleClick form your base class (the default implementation fires the DoubleClick event).

To only fire the Click event for left clicks, you need to override OnMouseDown and then determine which mouse button is down. Store that as a field. In an override to OnClick, only call base.OnClick if the left mouse button was pressed. A click occurs after a mouse button is pressed and released, so at the time the event is fired no mouse is pressed:
private bool leftMouse;
protected override void OnMouseDown(MouseEventArgs e)
{
  leftMouse = e.Button == MouseButtons.Left;
  base.OnMouseDown(e);
}
protected override void OnClick(EventArgs e)
{
  if (leftMouse)
    base.OnClick(e);
}
There is no need to check the current mouse configuration for the user since Windows will translate right-clicks to left-clicks if the mouse is re-orientied for left-handed users.

Why doesn't the Click event use the MouseEventHandler (which would dictate that the event pass a MouseEventArgs parameter)? Because it's in response to a mouse press and release as I mentioned above. To store this state data when not necessary is very wasteful. Only in rare cases like yours would it be necessary, so the Framework gives you the means to define such state variables.

If ever you need the position of the mouse or the buttons being pressed anywhere in your code, you can use the static Control.MousePosition and Control.MouseButtons properties. Keep in mind that the Control.MousePosition returns screen coordinate (relative to the upper-right of the screen), so you need to convert them to client-coordinates to typically be of any use. To do this, call the instance method Control.PointToClient on whichever Control requires the client-coordinates in regard to its extents.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralTabPage and DataGrid - weird behavor Pin
Wjousts21-Dec-04 6:23
Wjousts21-Dec-04 6:23 
GeneralUsing WMI Pin
realmontanakid21-Dec-04 4:58
realmontanakid21-Dec-04 4:58 
GeneralRe: Using WMI Pin
Heath Stewart21-Dec-04 12:41
protectorHeath Stewart21-Dec-04 12:41 
GeneralC# app stopping windows from shutting down Pin
mikey_g21-Dec-04 2:56
mikey_g21-Dec-04 2:56 
GeneralRe: C# app stopping windows from shutting down Pin
Michael Potter21-Dec-04 5:07
Michael Potter21-Dec-04 5:07 
General.NET DLL with Main() method to be put on separate process Pin
Kausthubh Rajendran21-Dec-04 2:47
Kausthubh Rajendran21-Dec-04 2:47 
GeneralRe: .NET DLL with Main() method to be put on separate process Pin
CoolDadTx21-Dec-04 4:02
CoolDadTx21-Dec-04 4:02 
QuestionCompiler directive for classname/membername insert ? Pin
fracalifa21-Dec-04 2:26
fracalifa21-Dec-04 2:26 
AnswerRe: Compiler directive for classname/membername insert ? Pin
Daniel Turini21-Dec-04 4:37
Daniel Turini21-Dec-04 4:37 
AnswerRe: Compiler directive for classname/membername insert ? Pin
leppie21-Dec-04 9:38
leppie21-Dec-04 9:38 
GeneralDoubleBuffer problem .. Pin
Sharpoverride21-Dec-04 1:28
Sharpoverride21-Dec-04 1:28 
GeneralRe: DoubleBuffer problem .. Pin
Gary Thom21-Dec-04 4:39
Gary Thom21-Dec-04 4:39 
GeneralRe: DoubleBuffer problem .. Pin
Dave Kreskowiak21-Dec-04 5:28
mveDave Kreskowiak21-Dec-04 5:28 
GeneralRe: DoubleBuffer problem .. Pin
Heath Stewart21-Dec-04 12:38
protectorHeath Stewart21-Dec-04 12:38 
GeneralRe: DoubleBuffer problem .. Pin
Dave Kreskowiak21-Dec-04 16:20
mveDave Kreskowiak21-Dec-04 16:20 
GeneralRe: DoubleBuffer problem .. Pin
Heath Stewart22-Dec-04 6:12
protectorHeath Stewart22-Dec-04 6:12 
GeneralRe: DoubleBuffer problem .. Pin
Dave Kreskowiak22-Dec-04 11:53
mveDave Kreskowiak22-Dec-04 11:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.