c# - How to create a context menu on datagrid and copy that value in winform -


i have seen many solutions didn't proper answer. answers confusing.

contextmenu.menuitems.add(new menuitem("update", copyclick)); datagridviewcell activecell = null;  private void copyclick(object sender, eventargs e) {    if (activecell != null && activecell.value != null)        clipboard.settext(activecell.value.tostring());  } 

currently using above code , copy current cell value want - if select row , press copy it copy first value row.

so how can that?

i hope helps.

var str = yourdatagridview.rows[activecell.rowindex].cells[0].value.tostring(); clipboard.settext(str); 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -