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 create mutil columns in datagridview (VB.2005) [modified]

How to create mutil columns in datagridview (VB.2005) [modified]

Scheduled Pinned Locked Moved Visual Basic
tutorial
10 Posts 7 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.
  • M Offline
    M Offline
    Member 3031069
    wrote on last edited by
    #1

    Hi, I have aplication that has datagridview, I need create 9000 columns by this code Dim i As Int32 For i = 1 To 9000 Dim colX As New DataGridViewTextBoxColumn colX.HeaderText = i.ToString colX.Name = "txt" colX.FillWeight = 1 colX.Dispose() 'colX.AutoSizeMode = DataGridViewAutoSizeColumnMode.None DataGridView1.Columns.Add(colX) Next But it very very slowly (to end this code it takes a long times(about 2 hour) Please tell me how to create it quickly Thanks for support !

    This will appear at the end of articles you submit to the Code Project

    modified on Friday, June 13, 2008 4:02 AM

    S H C 3 Replies Last reply
    0
    • M Member 3031069

      Hi, I have aplication that has datagridview, I need create 9000 columns by this code Dim i As Int32 For i = 1 To 9000 Dim colX As New DataGridViewTextBoxColumn colX.HeaderText = i.ToString colX.Name = "txt" colX.FillWeight = 1 colX.Dispose() 'colX.AutoSizeMode = DataGridViewAutoSizeColumnMode.None DataGridView1.Columns.Add(colX) Next But it very very slowly (to end this code it takes a long times(about 2 hour) Please tell me how to create it quickly Thanks for support !

      This will appear at the end of articles you submit to the Code Project

      modified on Friday, June 13, 2008 4:02 AM

      S Offline
      S Offline
      Steven J Jowett
      wrote on last edited by
      #2

      9000 columns in a DataGrid view!!!!? :omg: First thing I would do is review your program design. Why would you want 9000 columns? How can 9000 columns fit on a screen and make any meaningful sense to anyone?

      Steve Jowett ------------------------- It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)

      1 Reply Last reply
      0
      • M Member 3031069

        Hi, I have aplication that has datagridview, I need create 9000 columns by this code Dim i As Int32 For i = 1 To 9000 Dim colX As New DataGridViewTextBoxColumn colX.HeaderText = i.ToString colX.Name = "txt" colX.FillWeight = 1 colX.Dispose() 'colX.AutoSizeMode = DataGridViewAutoSizeColumnMode.None DataGridView1.Columns.Add(colX) Next But it very very slowly (to end this code it takes a long times(about 2 hour) Please tell me how to create it quickly Thanks for support !

        This will appear at the end of articles you submit to the Code Project

        modified on Friday, June 13, 2008 4:02 AM

        H Offline
        H Offline
        Hasan Jaffal
        wrote on last edited by
        #3

        you mean 9000 rows !!! :omg: Microsoft didn't take in consideration that one day a developer will use 9000 column ! :wtf: ;P

        A M 2 Replies Last reply
        0
        • H Hasan Jaffal

          you mean 9000 rows !!! :omg: Microsoft didn't take in consideration that one day a developer will use 9000 column ! :wtf: ;P

          A Offline
          A Offline
          Ashfield
          wrote on last edited by
          #4

          Lord Hasan wrote:

          you mean 9000 rows

          I would have thought so, but his code is generatinmg columns - slowly!

          Bob Ashfield Consultants Ltd

          M 1 Reply Last reply
          0
          • M Member 3031069

            Hi, I have aplication that has datagridview, I need create 9000 columns by this code Dim i As Int32 For i = 1 To 9000 Dim colX As New DataGridViewTextBoxColumn colX.HeaderText = i.ToString colX.Name = "txt" colX.FillWeight = 1 colX.Dispose() 'colX.AutoSizeMode = DataGridViewAutoSizeColumnMode.None DataGridView1.Columns.Add(colX) Next But it very very slowly (to end this code it takes a long times(about 2 hour) Please tell me how to create it quickly Thanks for support !

            This will appear at the end of articles you submit to the Code Project

            modified on Friday, June 13, 2008 4:02 AM

            C Offline
            C Offline
            ChandraRam
            wrote on last edited by
            #5

            Member 3031069 wrote:

            Dim i As Int32 For i = 1 To 9000 Dim colX As New DataGridViewTextBoxColumn colX.HeaderText = i.ToString colX.Name = "txt" colX.FillWeight = 1 colX.Dispose() 'colX.AutoSizeMode = DataGridViewAutoSizeColumnMode.None DataGridView1.Columns.Add(colX) Next But it very very slowly (to end this code it takes a long times(about 2 hour)

            Are you sure it creates the columns? You have already disposed colX before adding...

            M 1 Reply Last reply
            0
            • C ChandraRam

              Member 3031069 wrote:

              Dim i As Int32 For i = 1 To 9000 Dim colX As New DataGridViewTextBoxColumn colX.HeaderText = i.ToString colX.Name = "txt" colX.FillWeight = 1 colX.Dispose() 'colX.AutoSizeMode = DataGridViewAutoSizeColumnMode.None DataGridView1.Columns.Add(colX) Next But it very very slowly (to end this code it takes a long times(about 2 hour)

              Are you sure it creates the columns? You have already disposed colX before adding...

              M Offline
              M Offline
              Member 3031069
              wrote on last edited by
              #6

              Yes, I have a mistake my code colx.dispose is commented Dim i As Int32 For i = 1 To 9000 Dim colX As New DataGridViewTextBoxColumn colX.HeaderText = i.ToString colX.Name = "txt" colX.FillWeight = 1 'colX.Dispose() 'colX.AutoSizeMode = DataGridViewAutoSizeColumnMode.None Next DataGridView1.Columns.Add(colX) :doh:

              This will appear at the end of articles you submit to the Code Project

              N 1 Reply Last reply
              0
              • H Hasan Jaffal

                you mean 9000 rows !!! :omg: Microsoft didn't take in consideration that one day a developer will use 9000 column ! :wtf: ;P

                M Offline
                M Offline
                Member 3031069
                wrote on last edited by
                #7

                No, I need to create 9000 column

                This will appear at the end of articles you submit to the Code Project

                J 1 Reply Last reply
                0
                • A Ashfield

                  Lord Hasan wrote:

                  you mean 9000 rows

                  I would have thought so, but his code is generatinmg columns - slowly!

                  Bob Ashfield Consultants Ltd

                  M Offline
                  M Offline
                  Member 3031069
                  wrote on last edited by
                  #8

                  Yes, It very very slowly, it take a long (about 2 hours) to create 9000 columns

                  This will appear at the end of articles you submit to the Code Project

                  1 Reply Last reply
                  0
                  • M Member 3031069

                    No, I need to create 9000 column

                    This will appear at the end of articles you submit to the Code Project

                    J Offline
                    J Offline
                    Jay Royall
                    wrote on last edited by
                    #9

                    What kind of dataset do you have which contains 9000 fields? Maybe there is a more appropriate control as I think that 9000 columns is beyond the scope of a datagridview control.

                    1 Reply Last reply
                    0
                    • M Member 3031069

                      Yes, I have a mistake my code colx.dispose is commented Dim i As Int32 For i = 1 To 9000 Dim colX As New DataGridViewTextBoxColumn colX.HeaderText = i.ToString colX.Name = "txt" colX.FillWeight = 1 'colX.Dispose() 'colX.AutoSizeMode = DataGridViewAutoSizeColumnMode.None Next DataGridView1.Columns.Add(colX) :doh:

                      This will appear at the end of articles you submit to the Code Project

                      N Offline
                      N Offline
                      Noctris
                      wrote on last edited by
                      #10

                      Are you absolutely, positivly, smack me in the face if i'm lying, sure you need 9000 columns ? This is not viewable or practical in any way ! Well. i was thinking about something like this: Dim dt As New DataTable For i As Integer = 1 To 9000 dt.Columns.Add(i.ToString) Next DataGridView1.DataSource = dt but you actually get an exception saying "sum of the columns "FillWeight" values cannot exceed 65535 For the rest however, the datatabe with the 9000 columns itself was build in something like 5 or 6 seconds...

                      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