1. Create a windows form application
2. add a button and spreadsheet and add the following code.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Spreadsheet1.Open("ManifestLoadOrder2019-01-24.xlsx")
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
AddHandler Spreadsheet1.ActiveGrid.CellContextMenuOpening, AddressOf ActiveGrid_CellContextMenuOpening
Spreadsheet1.IsCustomTabItemContextMenuEnabled = False
End Sub
Private Sub ActiveGrid_CellContextMenuOpening(sender As Object, e As CellContextMenuOpeningEventArgs)
'MessageBox.Show("Fired")
Try
If Spreadsheet1.ActiveGrid.CellContextMenu.Items.ContainsKey("PasteSpecial") = False Then
'//Adding Customized Menu item
Dim PasteSpecial = New ToolStripMenuItem() With {.BackColor = Color.White, .Name = "PasteSpecial"}
PasteSpecial.Text = "PasteSpecial"
AddHandler PasteSpecial.Click, AddressOf PasteSpecial_Click
Spreadsheet1.ActiveGrid.CellContextMenu.Items.Add(PasteSpecial)
End If
If Spreadsheet1.ActiveGrid.CellContextMenu.Items.ContainsKey("InsertCommentMenuItem") Then
Spreadsheet1.ActiveGrid.CellContextMenu.Items("InsertCommentMenuItem").Visible = False
End If
Catch ex As Exception
End Try
Spreadsheet1.ActiveGrid.Refresh()
End Sub
Private Sub PasteSpecial_Click(sender As Object, e As EventArgs)
End Sub
2. Start application and Right click a cell to display context menu. (Displays a context menu with Insert Comment hidden and PasteSpecial Visible.) or if you comment the msgbox you will see the event fires.
3. Click button to load spreadsheet (attached spreadsheet included - you may need to modify the path)
4. Right click a cell to display context menu. Normal context menu is visible with event not firing.