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
2589
MouseRightButton events on disabled cells
posted

Hello,

I try to handle right mouse button clicks on grid cells. This is what I do:

void xGrid_CellControlAttached(object sender, CellControlAttachedEventArgs e)
        {
            e.Cell.Control.MouseRightButtonDown += xGrid_CellMouseRightButtonDown;
            e.Cell.Control.MouseRightButtonUp += xGrid_CellMouseRightButtonUp;
        }

        private void xGrid_CellMouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            // do something
        }

        void xGrid_CellMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;
            
        }

But I have s a problem. Some cells have IsEnabled property set to False and I cannot handle right clicks on such cells. But I have to. Is there a workaround for this?

Thank you.

Parents
No Data
Reply
  • 40030
    Offline posted

    Hi, 

    Why are you disabling the cells?  Are you disabling entire column's or just specific cells in certain rows / columns?

    Could you achieve what you're looking for with a "disabled" style instead?

    As for how you're attaching the event, you need to be careful, b/c you're going to wind up hooking the same event handler to the same control multiple times, as cell controls become recycled, so be sure to call -= before attaching a new event handler. 

    -SteveZ

Children
No Data