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
Post a Comment