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. Adding Columns in DataGrid at run time

Adding Columns in DataGrid at run time

Scheduled Pinned Locked Moved C#
help
31 Posts 21 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.
  • X Xiangyang Liu

    Perhaps a fast forward/backward button would help?

    My .NET Business Application Framework My Home Page

    D Offline
    D Offline
    Dave Kreskowiak
    wrote on last edited by
    #22

    Even at moving 1,000 columns at a time, that's still 12.5 clicks to see the middle of the table. No matter how you bandaid this, it's still a horrible "solution".

    A guide to posting questions on CodeProject[^]
    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
         2006, 2007

    X D 2 Replies Last reply
    0
    • D Dave Kreskowiak

      Even at moving 1,000 columns at a time, that's still 12.5 clicks to see the middle of the table. No matter how you bandaid this, it's still a horrible "solution".

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      X Offline
      X Offline
      Xiangyang Liu
      wrote on last edited by
      #23

      Dave Kreskowiak wrote:

      No matter how you bandaid this, it's still a horrible "solution".

      As I recall, the original problem is that the initial poster can't create that many columns in a grid. My "solution" avoids the difficulty of creating that many columns, it is not intended to answer the question of how the hell the users are going to use the application. :) I agree with you that it is a bad design in the first place (that the app needs to create so many columns in a grid).

      My .NET Business Application Framework My Home Page

      1 Reply Last reply
      0
      • D Dave Kreskowiak

        Even at moving 1,000 columns at a time, that's still 12.5 clicks to see the middle of the table. No matter how you bandaid this, it's still a horrible "solution".

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        D Offline
        D Offline
        daniilzol
        wrote on last edited by
        #24

        Dave Kreskowiak wrote:

        Even at moving 1,000 columns at a time, that's still 12.5 clicks to see the middle of the table. No matter how you bandaid this, it's still a horrible "solution".

        Not that I advocate continuing on a design path doomed to fail, but you could always have "Jump To" button which would work just fine, maybe even acceptable to a given client assuming it was the same client that came up with 25,000 columns requirement.

        1 Reply Last reply
        0
        • A aloktambi

          Dear Sir, I am facing one problem in DataGrid. i want to add many columns in DataGrid at runtime .because this is requirement of our applcation. i want to add around 25000 columns at runtime. but when i add columns at run time, application hang up or it will taking much much time to add columns in DataGrid. so any one suggest me the best solution of display 25000 columns in DataGrid

          realJSOPR Offline
          realJSOPR Offline
          realJSOP
          wrote on last edited by
          #25

          I think you need to re-design your application. Twenty five THOUSAND columns? I'm almost afraid to ask how many rows you anticipate having...

          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

          1 Reply Last reply
          0
          • J Justin Perez

            Do you mean 25,000 ROWS? I can't think of any reason a table would need 25,000 columns.

            I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")

            W Offline
            W Offline
            W Balboos GHB
            wrote on last edited by
            #26

            My current employer hired a contractor who, himself, contracted out some software to India. It was textbook quality work - in other words, lacking insight. It was, after some debates (read: swallow pride) relegated to the scrap-heap - unused. This would seem to be an even more extreme (and certainly more amusing) example of meeting design specs as would a thoughtless drone. Management often seems to have a special skill at managing to muck things up. First there was a make-or-buy -> make was cheaper (until they learned that maintainence, custom modifications, upgrades, etc. cost money, too.). Next, they decided if we have to 'make' our software, let's get it done cheap in some distant land. Turns out that it's not so cheap, after all: once you factor in the extra time in getting the specs understood, and fix after fix on items that should have (would have!) been common sense if it were done home-grown. Can't wait to see what's next!

            "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

            J M 2 Replies Last reply
            0
            • D Dave Kreskowiak

              There's no way to create that many columns that fast. You're ARE going to have to find a different way to present your data. Just scrolling that many columns is going to be painfully slow. On a 19" monitor, with all of these columns widths set at, say, a half inch wide, you're DataGrid would be almost A QUARTER OF A MILE (0.4km) WIDE!! A bit excessive, wouldn't you say? This sounds more like a job for some kind of graph, not a DataGrid.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007

              T Offline
              T Offline
              TJoe
              wrote on last edited by
              #27

              You are assuming there are only 25000 columns, if there are more peaks then there are more columns: From the author of the thread: "For 10 peaks Column Count will be 363 For 25 peaks Column Count will be 1608 For 50 peaks Column Count will be 5683 For 100 peaks Column Count will be 21333 For 150 peaks Column Count will be 46983 For 200 peaks Column Count will be 82633 " So it may be closer to a mile :laugh:

              Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com

              1 Reply Last reply
              0
              • W W Balboos GHB

                My current employer hired a contractor who, himself, contracted out some software to India. It was textbook quality work - in other words, lacking insight. It was, after some debates (read: swallow pride) relegated to the scrap-heap - unused. This would seem to be an even more extreme (and certainly more amusing) example of meeting design specs as would a thoughtless drone. Management often seems to have a special skill at managing to muck things up. First there was a make-or-buy -> make was cheaper (until they learned that maintainence, custom modifications, upgrades, etc. cost money, too.). Next, they decided if we have to 'make' our software, let's get it done cheap in some distant land. Turns out that it's not so cheap, after all: once you factor in the extra time in getting the specs understood, and fix after fix on items that should have (would have!) been common sense if it were done home-grown. Can't wait to see what's next!

                "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                J Offline
                J Offline
                Jesse Chunn
                wrote on last edited by
                #28

                This is not a management problem. This is a programmer problem. This data is obviously not displayable in the way this programmer is trying to display it. Excel can't even begin to handle that. Anyone that would even consider having a datagrid with 25000 columns, or even 2500 columns, or even 250 columns, is clearly not ready to be doing UI design. The requirement is NOT to have 25000 columns in a datagrid. The requirement is to give the user access to 25000 peices of heirarchically(sp?) related information. That is more like a treeview or a nested datagrid, or some other type of "drill-down" UI. Having said all that, if you were to actually try to implement this as a datagrid in a way that was fast enough to use, you would have to virtualize the datagrid so that it loads as the user scrolls, and unloads the portion that has scrolled off-screen.

                Standard answer: It can be done in two weeks, provided nothing unexpected happens.

                W 1 Reply Last reply
                0
                • J Jesse Chunn

                  This is not a management problem. This is a programmer problem. This data is obviously not displayable in the way this programmer is trying to display it. Excel can't even begin to handle that. Anyone that would even consider having a datagrid with 25000 columns, or even 2500 columns, or even 250 columns, is clearly not ready to be doing UI design. The requirement is NOT to have 25000 columns in a datagrid. The requirement is to give the user access to 25000 peices of heirarchically(sp?) related information. That is more like a treeview or a nested datagrid, or some other type of "drill-down" UI. Having said all that, if you were to actually try to implement this as a datagrid in a way that was fast enough to use, you would have to virtualize the datagrid so that it loads as the user scrolls, and unloads the portion that has scrolled off-screen.

                  Standard answer: It can be done in two weeks, provided nothing unexpected happens.

                  W Offline
                  W Offline
                  W Balboos GHB
                  wrote on last edited by
                  #29

                  Actually, we are in agreement on this point. Rereading who I expressed my (two) points, I see how you would have replied as you did. My fault. The programmer was referred to as a . . . "drone". The management was being chastised for being concerned with cheap work instead of good work. They really don't understand (why else why would they be managers?) that the body of knowledge gained by experience implimented in a program (or other creative outlet) is a substantial "Value Added".

                  "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                  1 Reply Last reply
                  0
                  • A aloktambi

                    Dear Sir, I am facing one problem in DataGrid. i want to add many columns in DataGrid at runtime .because this is requirement of our applcation. i want to add around 25000 columns at runtime. but when i add columns at run time, application hang up or it will taking much much time to add columns in DataGrid. so any one suggest me the best solution of display 25000 columns in DataGrid

                    A Offline
                    A Offline
                    Alan Balkany
                    wrote on last edited by
                    #30

                    The obvious solution is to use a virtual table, i.e. only generate the rows and columns that are currently visible on screen. When the user scrolls this huge table, simply get the values of the visible cells and the visible row/column headers, and display them.

                    1 Reply Last reply
                    0
                    • W W Balboos GHB

                      My current employer hired a contractor who, himself, contracted out some software to India. It was textbook quality work - in other words, lacking insight. It was, after some debates (read: swallow pride) relegated to the scrap-heap - unused. This would seem to be an even more extreme (and certainly more amusing) example of meeting design specs as would a thoughtless drone. Management often seems to have a special skill at managing to muck things up. First there was a make-or-buy -> make was cheaper (until they learned that maintainence, custom modifications, upgrades, etc. cost money, too.). Next, they decided if we have to 'make' our software, let's get it done cheap in some distant land. Turns out that it's not so cheap, after all: once you factor in the extra time in getting the specs understood, and fix after fix on items that should have (would have!) been common sense if it were done home-grown. Can't wait to see what's next!

                      "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                      M Offline
                      M Offline
                      Mikkel Toudal Kristiansen
                      wrote on last edited by
                      #31

                      I can't help thinking about a quote from Uncle Bob (Robert C. Martin at ObjectMentor): When a customer comes up to you with his cell phone and says: "I need a bigger antenna!" You should think "He needs better reception on his cell phone" and not "He wants the mother of all cell phone antennas, 'cause it is 15 inches long" You should always ask yourself, "Why do they want that?", try putting yourself in your customer's shoes.

                      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