how can i display the selected row in datagridview to label?

Recommended Answers

All 3 Replies

Private Sub DataGridView1_CellEnter(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellEnter
    If (DataGridView1.RowCount > 1) And (DataGridView1.CurrentCell.Value IsNot Nothing) Then
        Label1.Text = DataGridView1.CurrentCell.Value.ToString
    End If

End Sub

Thank you. Its a big help :)
what if i selected a row in datagridview then there's a message in the label
like for example i click one of the rows then on the label says" if you buy this product you will have a free..."

@Glenda I think that easy as you already know where you want that to be visible which means you will have to modify the

Label1.Text = DataGridView1.CurrentCell.Value.ToString

to what ever you want, but I think you will have to have some sort of verification if you will have more then one option so that the displayed message will correspond to a correct DataGridView Item.

Be a part of the DaniWeb community

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