Selecting field from DataGrid when using a Context Menu

  • Thread starter Thread starter David Elliott
  • Start date Start date
D

David Elliott

I created a context menu and bound it to the data grid
this.dataGrid1.ContextMenu = this.contextMenu1;
This works fine when I right click.

What I am trying to do is to capture the data that is in the specific DataGrid box that
the context menu was created on. I am then going to pass it to another winform.

The functionality that I am looking for is if you left click on some code in Visual Studio
and then right click and select copy. Do a paste somewere else . Whatever line you
were on was selected for the copy.

Any thoughts would be appreciated.

Dave

(e-mail address removed)
 
Hello David,

Upon displaying the context menu, get mouse pointer coordinates, translate
them into DataGrid's client coordinate system, perform a HitTest, determine
the row number and the column number and then query data grid's Item indexer
for the cell contents.

There probably exists a simplier solution, but here is something to at least
start your investigation with.
 
Back
Top