Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
315
Cell Button and Right Click Issue
posted

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

 

 

  • 37774
    Suggested Answer
    posted

    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

  • 3565
    Suggested Answer
    posted

    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.

  • 3565
    posted

    Are you using an editor control for the column?