Default behavior is whole cell gets selected. I need user to be able to select part of text, and then use the selected part in context menu event handlers. What complicates things even more is that the only method I know of to get selected part of a cell's text is to get underlying control, something like
I guess I could create myself a special type of DataGridViewColumn that looks and acts as if it's ReadOnly i.e. cell's graphics does not change at all when in edit mode, no cursor appears and (somehow) does not allow user change text only select it. Looks a bit complicated but probably doable. Or is there a better way? Maybe there's already something like that, or a third party library for this?
TextBox tb = (TextBox)myDataGridView.EditingControl; string txt = tb.SelectedText;
however ReadOnly cells have no EditingControl (I think, haven't tested yet).I guess I could create myself a special type of DataGridViewColumn that looks and acts as if it's ReadOnly i.e. cell's graphics does not change at all when in edit mode, no cursor appears and (somehow) does not allow user change text only select it. Looks a bit complicated but probably doable. Or is there a better way? Maybe there's already something like that, or a third party library for this?
Last edited: