Ok so for some reason I can't get the current item I selected in my datagrid to display on my textboxes
I'm new to vb net and programming itself so please bear with me.
here's my code:
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDbConnection
Dim ds As New DataSet
Dim dt As New DataTable
Dim da As New OleDbDataAdapter
Dim i As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = " Provider = microsoft.jet.oledb.4.0; data source = C:\Users\Judz\Desktop\userpass.mdb"
con.Open()
datagridShow()
End Sub
Private Sub datagridShow()
ds.Tables.Add(dt)
da = New OleDbDataAdapter("select * from userpass", con)
da.Fill(dt)
DataGridView1.DataSource = dt.DefaultView
con.Close()
End Sub
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
TextBox1.Text = DataGridView1.Item(0, e.RowIndex).Value.ToString
TextBox2.Text = DataGridView1.Item(1, e.RowIndex).Value.ToString
TextBox3.Text = DataGridView1.Item(2, e.RowIndex).Value.ToString
End Sub
I already tried other codes like
"TextBox2.Text = DataGridView1.CurrentCell.Value.ToString"
or
"TextBox2.Text = DataGridView1.CurrentRow.Cells(1).Value.ToString"
No changes whatsoever...
Please help me I'm really frustrated by this.
Thanks.