简体   繁体   中英

DataGridView VB.NET Displaying Data in New Window on click

Ok just a quick question. I have a form in VB.NET that displays information from a database in a datagrid format. I was curious, is there a way that you can click on a row in a datagrid and it bring up a new form? I think it would be cool to have it to where you can select the row and it bring up a new window with textboxes that more readily display the forms information. Thanks :)

I understand that what you mean is selecting the whole row, that is, clicking on the "row header" (on the left-hand-side), in that case you should rely on the RowHeaderMouseClick Event . Sample code for DataGridView1 :

Private Sub DataGridView1_RowHeaderMouseClick(sender As Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.RowHeaderMouseClick
    MessageBox.Show("You have selected row No. " & e.RowIndex.ToString())

    'Dim curForm As Form = New Form
    'With curForm
    '     'Definition of the form
    '    .Show()
    'End With
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM