Hi,
I have a question regarding ColumnHeaderMouseClick, ContextMenuStrip, and DataGridViews (pew - those descriptive but LONG names!).
I want to set a contextmenustrip on my datagridviews' column header cells/column header rows. I inherit my forms from a parent form and there I also set some settings for each datagridview, as pictured below (it works great so feel free to use it in your own projects).
Now, in this DGVSettings sub I want to set a contextmenustrip (such as DGV.onColumnHeaderMouseClick = SubRightClick() and in that new sub check for right clicks and if appropriate show the contextmenustrip). However, I can't figure out how to write this. Any ideas?
Best wishes for the new year!
/Pettrer
I have a question regarding ColumnHeaderMouseClick, ContextMenuStrip, and DataGridViews (pew - those descriptive but LONG names!).
I want to set a contextmenustrip on my datagridviews' column header cells/column header rows. I inherit my forms from a parent form and there I also set some settings for each datagridview, as pictured below (it works great so feel free to use it in your own projects).
VB.NET:
Private Sub Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim kontrollen As Control = Me.GetNextControl(Me, True)
Do Until kontrollen Is Nothing
If TypeOf kontrollen Is DataGridView Then
dgvSettings(kontrollen)
ElseIf TypeOf kontrollen Is Button Then
'...
End If
kontrollen = Me.GetNextControl(kontrollen, True)
Loop
End Sub
Private Sub dgvSettings(ByRef DGV As DataGridView)
DGV.AllowUserToResizeColumns = True
DGV.AllowUserToResizeRows = False
'...
End Sub
Now, in this DGVSettings sub I want to set a contextmenustrip (such as DGV.onColumnHeaderMouseClick = SubRightClick() and in that new sub check for right clicks and if appropriate show the contextmenustrip). However, I can't figure out how to write this. Any ideas?
Best wishes for the new year!
/Pettrer