Jobs
Author: Gehan Fernando Date Submitted: 3/15/2007 Category: Forms Compatibility: .NET This code has been accessed 8160 times.
Email Yourself this snippet:
No declarations
Code
Public Class Form1 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