要自己写一个右键菜单,在右键菜单的一个Item的Click事件里处理Copy。实例代码如下。- Private menu As New ContextMenuStrip()
- Private Sub Form1_Load(sender As Object, e As EventArgs)
- menu.Items.Add("Copy")
- AddHandler menu.Items(0).Click, AddressOf CopyItem_Click
- Me.gcMultiRow.ContextMenuStrip = menu
- AddHandler Me.gcMultiRow.EditingControlShowing, AddressOf gcMultiRow_EditingControlShowing
- End Sub
- Private Sub gcMultiRow_EditingControlShowing(sender As Object, e As EditingControlShowingEventArgs)
- e.Control.ContextMenuStrip = menu
- End Sub
- Private Sub CopyItem_Click(sender As Object, e As EventArgs)
- If EditingActions.Copy.CanExecute(Me.gcMultiRow) Then
- EditingActions.Copy.Execute(Me.gcMultiRow)
- End If
- End Sub
复制代码 |