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. How to set row header labels in a Datagrid?

How to set row header labels in a Datagrid?

Scheduled Pinned Locked Moved C#
tutorialquestion
9 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.
  • W Offline
    W Offline
    work_to_live
    wrote on last edited by
    #1

    Sounds like something that should be simple enough, but I can't find anything on the topic. I have noticed a few references, but they're not encouraging... Words to the effect that it can't be done. Thanks.

    F 1 Reply Last reply
    0
    • W work_to_live

      Sounds like something that should be simple enough, but I can't find anything on the topic. I have noticed a few references, but they're not encouraging... Words to the effect that it can't be done. Thanks.

      F Offline
      F Offline
      Frank Olorin Rizzi
      wrote on last edited by
      #2

      If you want to set them at design time, use the properties of the data grid... Click on the data Grid; in the Properties panel, you should find a row for "TableStyles" with value "(Collection)" and a "..." button. Click on that, and you access the dialog through which you can set up the table style... you can add a new table style (or modify one that you already have), and in the right-hand side of this dialog you should find the Misc > GridColumnStyles property (with value "(Collection)" and the "..." button). Click on the "..." button to access the dialog to set up the column styles for the given table style. You can add a new column style or modify a pre-existing one. Each such column style has a HeaderText property you can set as needed. If you wish to do all this at run-time, I suggest doing it once at design time and taking a look at the code generated by the Studio for you... HTH, FOR

      W 1 Reply Last reply
      0
      • F Frank Olorin Rizzi

        If you want to set them at design time, use the properties of the data grid... Click on the data Grid; in the Properties panel, you should find a row for "TableStyles" with value "(Collection)" and a "..." button. Click on that, and you access the dialog through which you can set up the table style... you can add a new table style (or modify one that you already have), and in the right-hand side of this dialog you should find the Misc > GridColumnStyles property (with value "(Collection)" and the "..." button). Click on the "..." button to access the dialog to set up the column styles for the given table style. You can add a new column style or modify a pre-existing one. Each such column style has a HeaderText property you can set as needed. If you wish to do all this at run-time, I suggest doing it once at design time and taking a look at the code generated by the Studio for you... HTH, FOR

        W Offline
        W Offline
        work_to_live
        wrote on last edited by
        #3

        I don't have a problem with column headers, and I am creating them at run-time. I can't figure out how to label the rows!

        F 1 Reply Last reply
        0
        • W work_to_live

          I don't have a problem with column headers, and I am creating them at run-time. I can't figure out how to label the rows!

          F Offline
          F Offline
          Frank Olorin Rizzi
          wrote on last edited by
          #4

          [quote] I don't have a problem with column headers, and I am creating them at run-time. [/quote] Ooops ! My bad... sorry. I don't know if/how you could set the row headers... ALl I can think of is the RowHeaderWidth property of the data grid to set the width, and the RowHeaderVisible property of the TableStyles to determine whether they are visible or not, but I've never seen a place where you can set a row header label (or such...)... I wouldn't be surprised if this is not allowed, since the DataGrid uses the row header (if they are visible) to place the + symbol for a record leading to child records in another table... Wish I could be more helpfull, FOR

          W 1 Reply Last reply
          0
          • F Frank Olorin Rizzi

            [quote] I don't have a problem with column headers, and I am creating them at run-time. [/quote] Ooops ! My bad... sorry. I don't know if/how you could set the row headers... ALl I can think of is the RowHeaderWidth property of the data grid to set the width, and the RowHeaderVisible property of the TableStyles to determine whether they are visible or not, but I've never seen a place where you can set a row header label (or such...)... I wouldn't be surprised if this is not allowed, since the DataGrid uses the row header (if they are visible) to place the + symbol for a record leading to child records in another table... Wish I could be more helpfull, FOR

            W Offline
            W Offline
            work_to_live
            wrote on last edited by
            #5

            Thanks... I'm new to C#, and the datagrid control. I may have selected the wrong control for the task. I was looking for the following functionality... Row and column labels (datagrid has column labels, but not row labels) User editable fields within the table (datagrid supports this) bi-directional linkage to a datasource (datagrid supports this) cut and paste cells between tables (don't think so) The datagrid looked like a good choice, but I keep running into hurdles as if it was really meant for another application.

            F N 2 Replies Last reply
            0
            • W work_to_live

              Thanks... I'm new to C#, and the datagrid control. I may have selected the wrong control for the task. I was looking for the following functionality... Row and column labels (datagrid has column labels, but not row labels) User editable fields within the table (datagrid supports this) bi-directional linkage to a datasource (datagrid supports this) cut and paste cells between tables (don't think so) The datagrid looked like a good choice, but I keep running into hurdles as if it was really meant for another application.

              F Offline
              F Offline
              Frank Olorin Rizzi
              wrote on last edited by
              #6

              From what you describe, I would use the DataGrid. As far as the row headers... ..depending on why/how you need them, it may be that you could use the first column as "row header"... it's a work-around, and it might not suite your application, but that's all I can suggest right now... ..after all the dataGrid seems to fit all of your other requirements, except for the "cut-n-paste" across tables (hmmm... sounds like fun!). Is the data grid's data source going to link you to a DB? Are you looking for row headers because you know that you will always display a given number of rows, and that each row represents something specific? (in this case you might use simple labels, and separate text controls to display the data instead of the data grid..) FOR

              W 1 Reply Last reply
              0
              • F Frank Olorin Rizzi

                From what you describe, I would use the DataGrid. As far as the row headers... ..depending on why/how you need them, it may be that you could use the first column as "row header"... it's a work-around, and it might not suite your application, but that's all I can suggest right now... ..after all the dataGrid seems to fit all of your other requirements, except for the "cut-n-paste" across tables (hmmm... sounds like fun!). Is the data grid's data source going to link you to a DB? Are you looking for row headers because you know that you will always display a given number of rows, and that each row represents something specific? (in this case you might use simple labels, and separate text controls to display the data instead of the data grid..) FOR

                W Offline
                W Offline
                work_to_live
                wrote on last edited by
                #7

                I was considering using the first row as the label, and I might end up doing that if all else fails. Right now I'm taking another look at the ListView control, but I'm starting the learning curve all over again! :) I want to learn C#, but it's becoming difficult to resist the temptation to jump back to C++. Thanks again for your time.

                1 Reply Last reply
                0
                • W work_to_live

                  Thanks... I'm new to C#, and the datagrid control. I may have selected the wrong control for the task. I was looking for the following functionality... Row and column labels (datagrid has column labels, but not row labels) User editable fields within the table (datagrid supports this) bi-directional linkage to a datasource (datagrid supports this) cut and paste cells between tables (don't think so) The datagrid looked like a good choice, but I keep running into hurdles as if it was really meant for another application.

                  N Offline
                  N Offline
                  Not Active
                  wrote on last edited by
                  #8

                  Use the ItemCreated event to add whatever text you want to the datagrid row.

                  W 1 Reply Last reply
                  0
                  • N Not Active

                    Use the ItemCreated event to add whatever text you want to the datagrid row.

                    W Offline
                    W Offline
                    work_to_live
                    wrote on last edited by
                    #9

                    Sounds interesting, but I don't see the ItemCreated Event in the datagrid class... Like I said earlier, I'm new to C# and the property soup for the various controls. I'm probably missing something obvious! :)

                    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