How to add row header to DataGridView in vb.net
-
Hi, dear all, I add a DataGridView to a form, I want to add row header to it. I call the following function while initialize this gridview to wish to put the row number to the row header, but it didn't shown. Do I need to set some properties to dispaly row header?? Private Sub NumberAllRows(ByVal grdStudents As DataGridView) ' Add row headers. For i As Integer = 0 To grdStudents.Rows.Count - 1 grdStudents.Rows(i).HeaderCell.Value = i.ToString() Next i End Sub Thanks!
-
Hi, dear all, I add a DataGridView to a form, I want to add row header to it. I call the following function while initialize this gridview to wish to put the row number to the row header, but it didn't shown. Do I need to set some properties to dispaly row header?? Private Sub NumberAllRows(ByVal grdStudents As DataGridView) ' Add row headers. For i As Integer = 0 To grdStudents.Rows.Count - 1 grdStudents.Rows(i).HeaderCell.Value = i.ToString() Next i End Sub Thanks!
Solved, thanks!
-
Hi, dear all, I add a DataGridView to a form, I want to add row header to it. I call the following function while initialize this gridview to wish to put the row number to the row header, but it didn't shown. Do I need to set some properties to dispaly row header?? Private Sub NumberAllRows(ByVal grdStudents As DataGridView) ' Add row headers. For i As Integer = 0 To grdStudents.Rows.Count - 1 grdStudents.Rows(i).HeaderCell.Value = i.ToString() Next i End Sub Thanks!
That just works fine. Just check the width of your rowheader, if it is less then 30, numbers will not be shown. Make it 50 or so. I've checked this code which uses same code, and works fine. http://www.vb-helper.com/howto\_net\_datagridview\_row\_headers.html