Display row number in row header cell in datagridview
Display row number in row header cell in datagridview
Display row number in row header cell in datagridview
Display row number in row header cell in datagridview
Display row number in row header cell in datagridview
Display row number in row header cell in datagridview Display row number in row header cell in datagridview Display row number in row header cell in datagridview Display row number in row header cell in datagridview Display row number in row header cell in datagridview Display row number in row header cell in datagridview Display row number in row header cell in datagridview Display row number in row header cell in datagridview
Display row number in row header cell in datagridview Display row number in row header cell in datagridview
Display row number in row header cell in datagridview
Go Back  Xtreme Visual Basic Talk > > > Display row number in row header cell in datagridview


Reply
 
Thread Tools Display Modes
  #1  
Old 11-06-2008, 08:55 AM
BBauer42's Avatar
BBauer42 BBauer42 is offline
Contributor
 
Join Date: Dec 2005
Location: CT, USA
Posts: 448
Default Display row number in row header cell in datagridview


I am trying to show the row number in the row header cell. Here is my code:

Code:
Private Sub dgridRegisters_RowEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgridRegisters.RowEnter For rowIndex As Integer = 0 To dgridRegisters.RowCount - 1 dgridRegisters.Rows(rowIndex).HeaderCell.Value = rowIndex + 1 Next rowIndex dgridRegisters.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders End Sub

However, no numbers or strings or anything ever shows.... why would that be? Is there some property for the DataGridView that I need to change to allow text to be displayed in the header columns? Thanks.
__________________
www.sportsloon.com
Reply With Quote
  #2  
Old 11-06-2008, 09:20 AM
BBauer42's Avatar
BBauer42 BBauer42 is offline
Contributor
 
Join Date: Dec 2005
Location: CT, USA
Posts: 448
Default

It seems the column widths have to be bigger for this to work... i have created this function that you can pass a datagridview to. Call it in the dgv_RowEnter event and viola!

Code:
Public Sub AutoNumberDataGridRows(ByVal dgv As DataGridView) Dim rowNumber As Integer = 1 For Each row As DataGridViewRow In dgv.Rows If row.IsNewRow Then Continue For row.HeaderCell.Value = rowNumber.ToString rowNumber = rowNumber + 1 Next End Sub
__________________
www.sportsloon.com
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Display row number in row header cell in datagridview
Display row number in row header cell in datagridview
Display row number in row header cell in datagridview Display row number in row header cell in datagridview
Display row number in row header cell in datagridview
Display row number in row header cell in datagridview
Display row number in row header cell in datagridview Display row number in row header cell in datagridview Display row number in row header cell in datagridview Display row number in row header cell in datagridview Display row number in row header cell in datagridview Display row number in row header cell in datagridview Display row number in row header cell in datagridview
Display row number in row header cell in datagridview
Display row number in row header cell in datagridview
 
Display row number in row header cell in datagridview
Display row number in row header cell in datagridview
 
-->