all groups > vb.net controls > july 2006 >
You're in the

vb.net controls

group:

Datagrid row headers context menu


Datagrid row headers context menu rnettle
7/30/2006 12:59:50 AM
vb.net controls:
I have a datagridview on a form and what I want to do is add a context
menu to the datagridview row headers. So that when a user left clicks a
row header to highlight a grid row and then right clicks the row header
a context menu appears on that row header, your help would be much
appreciated.
Re: Datagrid row headers context menu Ken Tucker [MVP]
7/30/2006 7:31:01 AM
Hi,

I would show the menu by using the contextmenustrip's show
method if the user clicked the right button on the datagridviews mousedown
event

Private Sub DataGridView1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseDown
Dim hti As DataGridView.HitTestInfo
hti = DataGridView1.HitTest(e.Location.X, e.Location.Y)
If hti.Type = DataGridViewHitTestType.ColumnHeader And e.Button =
Windows.Forms.MouseButtons.Right Then
ContextMenuStrip1.Show(DataGridView1, e.Location)
End If
End Sub

Ken
--------------------------
[quoted text, click to view]

Re: Datagrid row headers context menu rnettle
8/1/2006 10:35:11 AM
Thanks Ken for the coding

[quoted text, click to view]
AddThis Social Bookmark Button