RadGridView detect CellClick event button


How can I detect which mouse button was pressed in event CellClick, or how can I detect which cell was pressed in event MouseClick.


You can detect which cell was clicked by using Mouse Click event.

Then you have to cast sender to RadGridView, and then use CurrentCell property.

GridViewCellInfo dataCell = (sender as RadGridView).CurrentCell;

If you want to which mouse button was clicked use:

if (e.Button == MouseButtons.Right) { //your code here }


I have written this answer thinking that you meant DataGridView; but this code might also be useful for RadGridView. What I usually do in these cases (with DataGridView) is relying on a global flag to coordinate two different events; just a few global flags should be OK. Sample code:

bool aCellWasSelected = false; private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { aCellWasSelected = true; } private void dataGridView1_MouseClick(object sender, MouseEventArgs e) { DataGridViewCell selectedCell = null; if (aCellWasSelected) { selectedCell = dataGridView1.SelectedCells[0]; MouseButtons curButton = e.Button; //Do stuff with the given cell + button } aCellWasSelected = false; }

NOTE: the proposed global-variable-based approach is NOT the ideal proceeding, but a practical solution pretty handy in quite a few DataGridView-related situations. If there is a direct solution, as in this case (as proposed in the other answer or, in DataGridView, the CellMouseClick event), you shouldn't ever use such an approach. I will let this answer as a reference anyway (for people looking for equivalent two-event-coordination situations, where no direct solution is present).


  • Nhibernate Error: BuidSessionFactory() Deadlock / Dropping Connection
  • Drag and Drop Function with Drawing Rectangle C# .net - Forms
  • Scroll by dragging with mouse
  • How to insert, update and delete records of a DataGridView to DataBase via BindingNavigator
  • How to Parse Json list in VB.NET Newtonsoft
  • Faster Method to Making DataGridViewRow's non-Visible
  • Vb.net 2010, how to use two filters at the same time
  • Winforms: Add a close “x” button in a UserControl
  • CRASH: *** -[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds [0 .. 9]
  • crash in __tcf_0
  • For loop with if condition on multiple R functions
  • JSR-330 support in Picocontainer : @Inject … @Named(\"xxx)
  • calculate gradient output for Theta update rule
  • Reading a file into a multidimensional array
  • Android application: how to use the camera and grab the image bytes?
  • uniform generation of points on 3D box
  • SharedPreferences or SQLite Database?
  • Insert new calendar with SyncAdapter- Calendar API Android
  • Ensure fsync did its job
  • Content-Length header not returned from Pylons response
  • How to clear text inside text field when radio button is select
  • Android fill_parent issue
  • Scrapy recursive link crawler
  • Q promise. Difference between .when and .then
  • Getting last autonumber in access
  • Is there a amazon webstore API for customers?
  • jquery mobile loadPage not working
  • Do create extension work in single-user mode in postgres?
  • Jquery - Jquery Wysiwyg return html as a string
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • Arrays break string types in Julia
  • PHP: When would you need the self:: keyword?
  • WPF Applying a trigger on binding failure
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Acquiring multiple attributes from .xml file in c#
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Java static initializers and reflection
  • How can I remove ASP.NET Designer.cs files?
  • How can i traverse a binary tree from right to left in java?
  • java string with new operator and a literal