Can't find anything on the internet, I'm thinking I'm missing something small.
I've got a list of column names in an access database, which should match DataGridViewTextBoxColumn I've created in my vb.net project. I want to use the column names in the access database to call the DataGridViewTextBoxColumn into my dgv. Sample code below:
Dim column1 As New DataGridViewTextBoxColumn
Dim column2 As New DataGridViewTextBoxColumn
Dim myheader As New DataGridViewTextBoxColumn
With column1
.Name = "column1"
.HeaderText = "Column 1"
.SortMode = DataGridViewColumnSortMode.NotSortable
.Width = 200
End With
With column2
.Name = "column2"
.HeaderText = "Column 2"
.SortMode = DataGridViewColumnSortMode.NotSortable
.Width = 400
End With
a = 0
Do While a < 2
myheader = ds.Tables("columnheadersdatabase").Rows(a).Item("J001") '//rows(a) = column1 and rows(a + 1) = column2
dgv.Columns.Add(myheader)
a += 1
Loop
the problem area is the below:
myheader = ds.Tables("columnheadersdatabase").Rows(a).Item("J001") '//rows(a) = column1 and rows(a + 1) = column2
dgv.Columns.Add(myheader)
I can seem to convert my access cell value to my DataGridViewTextBoxColumn (myheader). I tried using dim myheader as string, but that also doesn't work.
Has anybody got any ideas, any help will be much apprecated.
Aucun commentaire:
Enregistrer un commentaire