How can I detect which mouse button was pressed in event CellClick, or how can I detect which cell was pressed in event MouseClick.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
I have written this answer thinking that you meant
DataGridView
; but this code might also be useful forRadGridView
. What I usually do in these cases (withDataGridView
) is relying on a global flag to coordinate two different events; just a few global flags should be OK. Sample code: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).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.
If you want to which mouse button was clicked use: