So I've got an array of string values which I'd like to display in an unbound DataGridView. What is the process necessary to simply load strings into cells of a datagrid?
Ideally, we would go from this:
strArray(0) = "Ralph"
strArray(1) = "Johnston"
strArray(2) = "12/15/87"
to this (forgive the crude drawing):
| Ralph | Johnston | 12/15/87 |
I've had success getting values in with the code below, but this adds a new column onto the datagrid. What I want is to add data values into and existing column structure that I have in place. Thanks for your time.
Ideally, we would go from this:
strArray(0) = "Ralph"
strArray(1) = "Johnston"
strArray(2) = "12/15/87"
to this (forgive the crude drawing):
| Ralph | Johnston | 12/15/87 |
I've had success getting values in with the code below, but this adds a new column onto the datagrid. What I want is to add data values into and existing column structure that I have in place. Thanks for your time.
Code:
Dim strArray() As String = {"Ralph"}
Dim dt As New DataTable
dt.Columns.Add("FirstName", GetType(String))
Dim dr As DataRow = dt.NewRow
dr("FileName") = strArray(0)
dt.Rows.Add(dr)
' Set the datagrid's source
Me.dgMain.DataSource = dt
Comment