i want to load database table to datagridview to i can edit and update the column , I'm now using list view but i want to use gartagridview because its more ease to edit the data in it .
I'm using this code to show data in database in list view :
Public Sub showlistview()
Try
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter("select * from pay_pretalk where cust_id=" & pretalk_pay.TextBox4.Text & " order by sdate DESC ", con)
da.Fill(dt)
Dim myrow As DataRow
For Each myrow In dt.Rows
ListView1.Items.Add(myrow.Item(0))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(2))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(3))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(4))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(5))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(6))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(7))
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
how can i do the same in datagridview without showing the header of the database and use my custom header in the datagridview properties.
if i use this code to show data in datagridview :
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter("select * from pay_pretalk where cust_id=" & pretalk_pay.TextBox4.Text & " order by sdate DESC ", con)
da.Fill(dt)
DataGridView1.DataSource = dt
this show all table with the header !, but i have already add a custom header , so this miss up everything :(
