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. C#
  4. display row number in datagrid?

display row number in datagrid?

Scheduled Pinned Locked Moved C#
helpquestion
5 Posts 3 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.
  • S Offline
    S Offline
    sammyh
    wrote on last edited by
    #1

    What would be the best way to display row numbers in a datagrid? Simply 1,2,3,4,5, etc. Thanks for any help. -Sam

    M 1 Reply Last reply
    0
    • S sammyh

      What would be the best way to display row numbers in a datagrid? Simply 1,2,3,4,5, etc. Thanks for any help. -Sam

      M Offline
      M Offline
      Marc Clifton
      wrote on last edited by
      #2

      sammyh wrote: What would be the best way to display row numbers in a datagrid? Simply 1,2,3,4,5, etc. Insert a column into the underlying DataTable and number it? Well, that's one idea. Probably not the best. Marc MyXaml Advanced Unit Testing YAPO

      H 1 Reply Last reply
      0
      • M Marc Clifton

        sammyh wrote: What would be the best way to display row numbers in a datagrid? Simply 1,2,3,4,5, etc. Insert a column into the underlying DataTable and number it? Well, that's one idea. Probably not the best. Marc MyXaml Advanced Unit Testing YAPO

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        The problem with that is once you sort the data your "row numbers" are off. Note that you must use the DataView's view of the row, not the DataTable. Through the CurrencyManager this is typically pretty easy, but I still don't know of a decent way off the top of my head to display and manage that data in a DataGrid. Thank goodness for the DataGridView[^] in .NET 2.0. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]

        S 1 Reply Last reply
        0
        • H Heath Stewart

          The problem with that is once you sort the data your "row numbers" are off. Note that you must use the DataView's view of the row, not the DataTable. Through the CurrencyManager this is typically pretty easy, but I still don't know of a decent way off the top of my head to display and manage that data in a DataGrid. Thank goodness for the DataGridView[^] in .NET 2.0. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]

          S Offline
          S Offline
          sammyh
          wrote on last edited by
          #4

          DataGrid is such an awkward control, a major pain if you ask me. I'm looking forward to using .NET 2.0. Any tips to get me in the right direction. Or should I opt for a 3rd party control? Thanks, Sam

          H 1 Reply Last reply
          0
          • S sammyh

            DataGrid is such an awkward control, a major pain if you ask me. I'm looking forward to using .NET 2.0. Any tips to get me in the right direction. Or should I opt for a 3rd party control? Thanks, Sam

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #5

            If you're not tied to .NET 1.x, I suggest you download Visual Studio 2005 Beta 2[^] and start working with .NET 2.0. You can also get a Go-Live License[^], which is an addendum to the EULA that allows you to distribute applications based on beta 2 into the production environment. If you need a solution now, I would first suggest some serious research (googling, newsgroups at http://msdn.microsoft.com/newsgroups[^], etc) and then consider a third-party solution. If and when you do move to .NET 2.0 your third-party control would be obsolete, though - honestly - most third-party controls are pretty inexpensive and typically royalty-free. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]

            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