c# - Get value of data grid view first cell with context menu -


i have data grid view populated values. want right click item in data grid view, context menu pop up, there should select menu item first cell of selected row.
managed make context menu , item, i'm there. need somehow value of first row while selecting said item. tried use cell click method , works, have no clue how implement menu item click.

string value = ((datagridview)sender).rows[e.rowindex].cells[0].value.tostring(); 

okay managed play around problem , solve that: got value needed mouse down method , stored in global variable this:

private void datagridview1_mousedown(object sender, mouseeventargs e)     {         datagridview.hittestinfo hit = datagridview1.hittest(e.x, e.y);         if(hit.rowindex >= 0)         {             finalvalue = ((datagridview)sender).rows[hit.rowindex].cells[0].value.tostring();         }     } 

after click menu item can manage variable want. not exact solution problem described, hey , long works right? hope someone.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -