When you right-click the listview control, you can get the text content of the selected item.
Now we only need to get the text of the cell when right-clicking. The method is as follows:
1. Define the global mouse statusPoint m_mbrpt; // when right-clicking a point
2. process the message in listview when the mouse is pressedPrivate void listviewdomainmousedown (Object sender, mouseeventargs e) {// If (E. button = mousebuttons. right) {// obtain the mouse coordinate on the screen and convert it to the coordinate mark m_mbrpt = listview1.pointtoclient (control. mouseposition );}}
3. Right-click the menu and choose "copy message ".Private void copyitem_click (Object sender, eventargs e) {// copy the content of the specified table cell if (listview1.selecteditems. Count <= 0) {MessageBox. Show ("no transaction information is selected! "," Prompt ", messageboxbuttons. OK, messageboxicon. information); return;} // obtain the coordinates of the mouse on the screen and convert them to the coordinates of the list control (process and save them when you press the mouse) // point Pt = listview1.pointtoclient (m_mbrpt); listviewitem lstrow = listview1.getitemat (m_mbrpt.x, m_mbrpt.y); system. windows. forms. listviewitem. listviewsubitem lstcol = lstrow. getsubitemat (m_mbrpt.x, m_mbrpt.y); string strtext = lstcol. text; // set to clipboard setclipboardtext (strtext );}
4. Set clipboard contentPublic void setclipboardtext (string strtext) {try {clipboard. setdataobject (strtext);} catch (system. exception ex) {MessageBox. show (ex. message, "prompt", messageboxbuttons. OK, messageboxicon. error);} content from: http://blog.sina.com.cn/s/blog_8a7012cf0101f1je.html