by Gehan Fernando (47 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Thu 15th March 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Review Data From Data grid, In Easiest Way.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call LoadItems()
End Sub
Private Sub LoadItems()
For ForCount As Integer = 1 To 10
DataGridView1.Rows.Add()
Dim Row As Int16 = DataGridView1.Rows.Count
DataGridView1.Rows(Row - 1).Cells(0).Value = ForCount
DataGridView1.Rows(Row - 1).Cells(1).Value = ForCount & " Name And ForCount"
Next
End Sub
Private Sub DataGridView1_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
If DataGridView1.Rows.Count = 0 Or DataGridView1.CurrentRow.Index < 0 Then
Exit Sub
Else
TextBox1.Text = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(0).Value.ToString()
TextBox2.Text = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(1).Value.ToString()
End If
End Sub
End Class