How to create mutil columns in datagridview (VB.2005) [modified]
-
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
-
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
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)
-
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
you mean 9000 rows !!! :omg: Microsoft didn't take in consideration that one day a developer will use 9000 column ! :wtf: ;P
-
you mean 9000 rows !!! :omg: Microsoft didn't take in consideration that one day a developer will use 9000 column ! :wtf: ;P
-
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
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...
-
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...
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
-
you mean 9000 rows !!! :omg: Microsoft didn't take in consideration that one day a developer will use 9000 column ! :wtf: ;P
No, I need to create 9000 column
This will appear at the end of articles you submit to the Code Project
-
Lord Hasan wrote:
you mean 9000 rows
I would have thought so, but his code is generatinmg columns - slowly!
Bob Ashfield Consultants Ltd
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
-
No, I need to create 9000 column
This will appear at the end of articles you submit to the Code Project
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.
-
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
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...