DataGridView right-click menu/copy example?

后端 未结 2 978
生来不讨喜
生来不讨喜 2021-02-03 10:53

I have a DataGridView (dgv1) on my form. In a particular cell, I\'d like for the user to be able to right-click and choose \"COPY\" to copy the contents of the cell to the clip

2条回答
  •  爱一瞬间的悲伤
    2021-02-03 11:19

    You might want to create a contextmenustrip for the COPY option when you right click.

    And in the datagridview properties in the rightclick eventhandler, you link this contextmenustrip.

    And on clicking copy, you have another function where you say Clipboard.settext(Datagriditem.value)

    This link should help you figure out how to get the right click menu.

    right click context menu for datagridview

    And use the Clipboard.Setdataobject to get the data into clipboard.

提交回复
热议问题