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
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
Sorry, I meant the mouse click event.