buffdaemon_live
New member
- Joined
- Jun 13, 2008
- Messages
- 3
- Programming Experience
- Beginner
HI all,
I have a problem while displaying the data in the DataGridView using my custom column name
below is my code. I wanted to display the data in rows under the column like this:
Below is my source code:
"dgvInstructors" is my DataGridView name
Please help me with this.
I have a problem while displaying the data in the DataGridView using my custom column name
below is my code. I wanted to display the data in rows under the column like this:
ID Name
--- ------
1 silk
2 milk
Below is my source code:
VB.NET:
Dim objG As New systemClass
Dim sqlCon As SqlConnection
sqlCon = objG.dbSConnect
Dim SQL As String = "select id,name from products"
Dim da As New SqlDataAdapter(SQL, sqlCon)
Dim dt As New DataTable
da.Fill(dt)
"dgvInstructors" is my DataGridView name
VB.NET:
Me.dgvInstructors.ColumnCount = 2
Me.dgvInstructors.ColumnHeadersVisible = True
Dim columnHeaderStyle As New DataGridViewCellStyle
Me.dgvInstructors.ColumnHeadersDefaultCellStyle = columnHeaderStyle
'set the column header names
Me.dgvInstructors.Columns(0).Name = "ID"
Me.dgvInstructors.Columns(1).Name = "Name"
Me.dgvInstructors.Rows.Add(dt)
Please help me with this.