DataGridView and ContextMenuStrip
-
I have a DataGridView with an assigned ContextMenuStrip. When I right click on any cell in the grid that is read only, the contextmenu that I expect to see is displayed. However, when I right-click on a non-read only cell that is a DataGridViewTextBoxColumn, I get an unexpected context menu popup with "Cut, Copy, Paste, etc." built-in commands. Clearly this context menu popup is built-in to the DataGridView, but I see no event that would allow me to capture and cancel it from popping up, so I can override it with my preferred context menu. Does anyone know of a way I can prevent this built-in context menu from displaying when right clicking on a DataGridViewTextBoxColumn? Thank you...
-
I have a DataGridView with an assigned ContextMenuStrip. When I right click on any cell in the grid that is read only, the contextmenu that I expect to see is displayed. However, when I right-click on a non-read only cell that is a DataGridViewTextBoxColumn, I get an unexpected context menu popup with "Cut, Copy, Paste, etc." built-in commands. Clearly this context menu popup is built-in to the DataGridView, but I see no event that would allow me to capture and cancel it from popping up, so I can override it with my preferred context menu. Does anyone know of a way I can prevent this built-in context menu from displaying when right clicking on a DataGridViewTextBoxColumn? Thank you...
You can probably filter out the message sent when the user rightclicks on DataGridViewColumn. This can be done using PreFilterMessage method of IMessageFilter interface. And then you call show your own contextmenu. Dont know if any simple way exists for this.
"If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be 'meetings'." - Dave Barry
-
You can probably filter out the message sent when the user rightclicks on DataGridViewColumn. This can be done using PreFilterMessage method of IMessageFilter interface. And then you call show your own contextmenu. Dont know if any simple way exists for this.
"If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be 'meetings'." - Dave Barry