datagridview with combobox column, its urgent,im new to vb.net

rajesh.forum

Well-known member
Joined
Sep 7, 2007
Messages
55
Programming Experience
Beginner
hi all,

im using a datagridview in which there r two combo columns.here im using context menu for a pop function.i need the combo boxvalues when i click the context menu item in any particular row.

also i used event of contextmenuclick(), am getting the combo box values for one row but if i click the next row i cudnt get the values..

the gridview rows are generated dynamically using datatable.
 
Get information about row in MouseDown on DataGridView, you can also call contextmenu with keyboard so you can the same information in this context too with KeyDown:
VB.NET:
Private Sub TestToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles TestToolStripMenuItem.Click
    MsgBox("you called contextmenu on datagridview row " & contextRow.ToString)
End Sub

Private contextRow As Integer

Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles DataGridView1.KeyDown
    If e.KeyCode = Keys.Apps _
    Or (e.Shift = True AndAlso e.KeyCode = Keys.F10) Then
        contextRow = DataGridView1.CurrentRow.Index
    End If
End Sub

Private Sub DataGridView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles DataGridView1.MouseDown
    If e.Button = Windows.Forms.MouseButtons.Right Then
        Dim hti As DataGridView.HitTestInfo = DataGridView1.HitTest(e.X, e.Y)
        contextRow = hti.RowIndex
    End If
End Sub
 
Back
Top