hello
in DataGridView1 control there is 3 items i want when you for etc
select item , "number 1" then do something like when i use listbox selected item

If ListBox1.SelectedItem = "1" Then
          textbox1.text="hello"
        end if

if
like
if DataGridView1.selected item ?

Recommended Answers

An example :

Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
    Dim i As Integer = DataGridView1.CurrentRow.Index
    With DataGridView1
            If DataGridView1.Item(0, i).Value = "1" Then
                textbox1.text="hello"
            End If 
    End With
End Sub
Jump to Post

All 2 Replies

Select the DataGridView in designer mode and examine the entries under the Events tab in the properties panel. You will see events like

CellClick
CellEnter
CellLeave
etc.

One of them should be what you are looking for.

An example :

Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
    Dim i As Integer = DataGridView1.CurrentRow.Index
    With DataGridView1
            If DataGridView1.Item(0, i).Value = "1" Then
                textbox1.text="hello"
            End If 
    End With
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.