We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Capture right click in cell when text selected

Thread ID:





19319 Sep 23,2004 12:58 PM UTC Jun 26,2009 04:34 PM UTC WinForms 8
Tags: GridControl
Asked On September 23, 2004 12:58 PM UTC

In my virtual grid, I would like to handle a right mouse click on a cell. I do get the CellClick event (then look for if right button was clicked), but only if the cell is not already selected. If the user is already editing a cell (text in the cell may or may not be selected), how can I get a (right) mouse click event? Thanks !

Administrator [Syncfusion]
Replied On September 23, 2004 02:45 PM UTC

Hi Dan, try to get a hold of the control inside the cell, e.g. Control c = grid.CellRenderers["TextBox"].Control; Once you have that control you can subscribe to its MouseDown event. Stefan

Replied On September 23, 2004 07:36 PM UTC

Thanks Stephan. So would I have to do that for all cells in the grid? Yikes, hope not. Maybe I''ll try subscribing to the event on the "current" cell when the selection selection changes.

Administrator [Syncfusion]
Replied On September 23, 2004 08:50 PM UTC

For each renderer in the CellRenderers collection only for the cell types you use. Typically that will only be a TextBox and ComboBox. The renderer is shared among cells ... But the best idea might be to handle the CurrentCellStartEditing and CurrentCellEndEditingComplete / CurrentCellEndEditingFailed events and subscribe/unsubscribe there from CurrentCell.Renderer.Control. Stefan

Replied On September 27, 2004 02:38 PM UTC

I think I have the correct "Renderer" class, but the OnClick event is protected. In the help, it mentions "... is called from GridSelectCellsMouseController ... How would I get that? I''m trying this: GridTextBoxCellRenderer r = grid.CellRenderers["TextBox"] as GridTextBoxCellRenderer; Or...GridTextBoxControl class in help seems to have all the right events (mostly inherited from Control base class), but not sure how to get that either.

Administrator [Syncfusion]
Replied On September 27, 2004 02:40 PM UTC

A renderer has a Control property which gives you access to the TextBox that is displayed in a TextBoxCellRenderer. TextBox has a public Click event. GridTextBoxCellRenderer r = grid.CellRenderers["TextBox"] as GridTextBoxCellRenderer; r.Control.Click += ... Stefan

Replied On September 27, 2004 03:41 PM UTC

Thanks Stephan. ...but the Control value is null. (Why I didn''t think that was it before posting the last message) r.Control is null this is in the same setup function where I''m hooking up the rest of my virtual grid events.

Administrator [Syncfusion]
Replied On September 27, 2004 05:23 PM UTC

Here is a little sample that uses CurrentCellGotFocus and CurrentCellLostFocus to subscribe to the cell control''s MouseUp event. I think you should be able to do something similar for the MouseDown. http://www.syncfusion.com/support/user/uploads/contextmenus.zip

Administrator [Syncfusion]
Replied On June 26, 2009 04:34 PM UTC

Am I the only one noticing that all of the KB links in these forums are dead since the website got revamped. e.g., see last post before mine; 404 error.
I often get some kind of "Parse error" on trying to get to links on older posts, too.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon