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

 

 

Parents
No Data
Reply
  • 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

Children