If you have a Datagridview with 2 columns, one is a TextBoxColumn and the other is a ButtonColumn:
Select the Text cell. Now highlight/select the text inside the cell and while selecting (holding mousebutton down) and if you move the mousecursor over the neighboring ButtonColumn and release the mousebutton, then the DatagridView fires CellContentClick for the button column even though I did MouseDown inside the textcell.
I would expect that for CellContentClick to be triggered, that MouseDown and MouseUp must both have been performed in the same Cell. My users also expect that.
Does anybody know a workaround/fix for this?
I usually avoid using
CellContentClick
and go forCellClick
.This not only avoids this weird behaviour but also other pitfalls of
CellContentClick
: User must actually hit the text to make it work, not the empty space around it.For some special cases this may even be fine, like when a cell is really large and one wants to discern clicking it for selection from clicking the content for editing.
But
CellClick
will work fine for normal as well as for button cells and others.Yes MSDN talks about usings it for
DataGridViewButtonColumns
but it is just a possible use and by no means reuqired.