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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Can we get A Name for the Row of DataGridView ...

Can we get A Name for the Row of DataGridView ...

Scheduled Pinned Locked Moved C#
6 Posts 3 Posters 1 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.
  • N Offline
    N Offline
    nassimnastaran
    wrote on last edited by
    #1

    Hi All ! Is it possible to Naming "Row" of A DataGridView as a Column "Header Text" . Thanks a Lot !

    P L 2 Replies Last reply
    0
    • N nassimnastaran

      Hi All ! Is it possible to Naming "Row" of A DataGridView as a Column "Header Text" . Thanks a Lot !

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      I'm not sure what you mean, but how about System.Windows.Forms.DataGridViewRowHeaderCell.Value ?

      N 1 Reply Last reply
      0
      • P PIEBALDconsult

        I'm not sure what you mean, but how about System.Windows.Forms.DataGridViewRowHeaderCell.Value ?

        N Offline
        N Offline
        nassimnastaran
        wrote on last edited by
        #3

        yes , but Not For Rows , I don't think exist any property for Row to put a Text ! Thanks !

        P 1 Reply Last reply
        0
        • N nassimnastaran

          Hi All ! Is it possible to Naming "Row" of A DataGridView as a Column "Header Text" . Thanks a Lot !

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          How about you adding a DataGridViewColumn which would then hold the names you choose? :)

          Luc Pattyn [My Articles] Nil Volentibus Arduum

          1 Reply Last reply
          0
          • N nassimnastaran

            yes , but Not For Rows , I don't think exist any property for Row to put a Text ! Thanks !

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Then explain more clearly what you want.

              System.Data.DataTable dt = new System.Data.DataTable() ;
              for ( int col = 0 ; col < 10 ; col++ )
              {
                dt.Columns.Add ( new System.Data.DataColumn ( col.ToString() ) ) ;
              }
              for ( int row = 0 ; row < 10 ; row++ )
              {
                System.Data.DataRow dr = dt.NewRow() ;
                for ( int col = 0 ; col < dt.Columns.Count ; col++ )
                {
                  dr \[ col \] = row \* col ;
                }
                dt.Rows.Add ( dr ) ;
              }
              this.dataGridView1.DataSource = dt ;
              for ( int row = 0 ; row < dt.Rows.Count ; row++ )
              {
                **this.dataGridView1.Rows \[ row \].HeaderCell.Value = row.ToString() ;**
              }
            

            This gives me a DataGridView showing a multiplication table with the row headers showing the row number.

            N 1 Reply Last reply
            0
            • P PIEBALDconsult

              Then explain more clearly what you want.

                System.Data.DataTable dt = new System.Data.DataTable() ;
                for ( int col = 0 ; col < 10 ; col++ )
                {
                  dt.Columns.Add ( new System.Data.DataColumn ( col.ToString() ) ) ;
                }
                for ( int row = 0 ; row < 10 ; row++ )
                {
                  System.Data.DataRow dr = dt.NewRow() ;
                  for ( int col = 0 ; col < dt.Columns.Count ; col++ )
                  {
                    dr \[ col \] = row \* col ;
                  }
                  dt.Rows.Add ( dr ) ;
                }
                this.dataGridView1.DataSource = dt ;
                for ( int row = 0 ; row < dt.Rows.Count ; row++ )
                {
                  **this.dataGridView1.Rows \[ row \].HeaderCell.Value = row.ToString() ;**
                }
              

              This gives me a DataGridView showing a multiplication table with the row headers showing the row number.

              N Offline
              N Offline
              nassimnastaran
              wrote on last edited by
              #6

              thanks for Ur Help , I wanted To give A Name for Each Row , that stored in a Combo Box !

              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