Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to add row header to DataGridView in vb.net

How to add row header to DataGridView in vb.net

Scheduled Pinned Locked Moved Visual Basic
csharptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andraw Tang
    wrote on last edited by
    #1

    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!

    A P 2 Replies Last reply
    0
    • A Andraw Tang

      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!

      A Offline
      A Offline
      Andraw Tang
      wrote on last edited by
      #2

      Solved, thanks!

      1 Reply Last reply
      0
      • A Andraw Tang

        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!

        P Offline
        P Offline
        Prerak Patel
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups