Ticket Q257821
Visible to All Users

Right-click focus cell and show context menu

created 15 years ago

In the gridview I am trying to handle the right-click on a cell to instantly show the context menu rather than having to first left click in the cell and then right click to get the context menu.
I have followed suggested in the Support center, however, my code has no effect - the cell does still not have a focused border and the context menu is not displayed. I have stepped through my code and found the focused row and column are set, the active editor is set appropriately based on the data type of the cell, and the appropriate context menu is set (some have custom context menus).
Here is the code I am using:
        private void gridView1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                GridView view = sender as GridView;
                GridHitInfo hitInfo = view.CalcHitInfo(e.Location);
                if (hitInfo.InRow)
                {
                    view.FocusedColumn = hitInfo.Column;
                    view.FocusedRowHandle = hitInfo.RowHandle;
                    view.ShowEditor();
                    view.ActiveEditor.SendMouse(e.Location, MouseButtons.Right);
                }
            }
        }
Thanks, any help will be greatly appreciated.
Terri

Show previous comments (4)
Anatol (DevExpress) 15 years ago

    Hello Terri,
    I've created a sample project. It appears that the first issue, demonstrated in the attached document, doesn't occur in it. The second issue is resolved by sending additional mouse events to the editor. Please let me know whether the result meets your requirements.
    Thanks,
    Anatol

    ?
    Unknown 15 years ago

      Yes - that does exactly what I want. Thanks for your help!
      Terri

      Anatol (DevExpress) 15 years ago

        You are always welcome.
        Thanks,
        Anatol

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.