Hi,
I have added a Cell Button in one of the Grids. I perform some action on the left click on it. But the CellButtonClick event also fires on Right click of the mouse. I want to avoid this. Can any one please suggest something simple.
Regards,
Hemesh
Sorry, I meant the mouse click event.
Hemesh,
Unfortunately, the Click event that is triggered doesn't really let you know which mouse button that was pressed, only that the control was clicked. Fortunately, since a Click event is really just a MouseDown followed by a MouseUp, you could keep track of this yourself in the MouseUp on whether to ignore the Click or not:
private MouseButtons lastMouseButtons;private void ultraGrid1_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e){ if (this.lastMouseButtons == MouseButtons.Left) { // Process the click string s = "BL"; }}private void ultraGrid1_MouseUp(object sender, MouseEventArgs e){ this.lastMouseButtons = e.Button;}
You should also take a look at this KB article in case you want to determine which UIElement the user has clicked on:
HOWTO:Taking action when right-clicking the WinGrid
Sometimes simply checking the grid.DisplayLayout.UIElement.LastElementEntered is enough as well.
-Matt
I was thinking if you had a reference to the editor control in the cell and captured the click event you could effectively pass a message to your button click event to tell it whether or not to execute the code. I don't think there are any event parameters passed in the button click event that will tell you what mouse button was used when the user clicked on it.
Are you using an editor control for the column?