473,320 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

.NET 2.0 DataGridView

Hello, I'm manually populating a DataGridView instead of using Data Binding.
How can I clear the contents of all the rows and/or header quickly? My
current method is to loop thru the grid backwards and delete each row
separately; which is kind of slow.

Thanks

Feb 15 '06 #1
3 1308
Why not just call the Clear method on the DataGridViewRowCollection
returned by the Rows property? Most collections will have a Clear method
which will clear all of the items.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"dm1608" <dm****@spam.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello, I'm manually populating a DataGridView instead of using Data
Binding. How can I clear the contents of all the rows and/or header
quickly? My current method is to loop thru the grid backwards and delete
each row separately; which is kind of slow.

Thanks

Feb 15 '06 #2
Can I see a sample of this?

My DataGridView is called ApplicationDataGridView and I do not see how I
would reference that.

I'm currently doing something like:

Dim i As Integer

If Me.ApplicationDataGridView.Rows.Count > 1 Then
For i = me.ApplicationDataGridView.Rows.Count -1 to 0 Step -1
Me.ApplicationDataGridView.Rows.Remove(Application sDataGridView.Rows(i))
Next
End If
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:e4**************@TK2MSFTNGP11.phx.gbl...
Why not just call the Clear method on the DataGridViewRowCollection
returned by the Rows property? Most collections will have a Clear method
which will clear all of the items.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"dm1608" <dm****@spam.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello, I'm manually populating a DataGridView instead of using Data
Binding. How can I clear the contents of all the rows and/or header
quickly? My current method is to loop thru the grid backwards and delete
each row separately; which is kind of slow.

Thanks


Feb 15 '06 #3
Have u tried setting the RowCount Property to 0?

"dm1608" <dm****@spam.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello, I'm manually populating a DataGridView instead of using Data
Binding. How can I clear the contents of all the rows and/or header
quickly? My current method is to loop thru the grid backwards and delete
each row separately; which is kind of slow.

Thanks

Feb 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DraguVaso | last post by:
Hi, I'm using the DataGridView in VB.NET 2.0. The DataSource is a Generic List of a custom class0: lstMyPersonnes = New List(Of clsPersonne). When I add a new clsPersonne to lstMyPersonnes,...
6
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I...
10
by: Henok Girma | last post by:
Hello Gurus, I want to save the state of an unbound DataGridView on my Windows Form application to an XML file so i can later load it back.. Basically, on my form I have a DataGridView, it's got...
3
by: Rich | last post by:
Hello, I am populating a datagridview from a datatable and filtering the number of rows with a dataview object. Is there a way to retrieve the rows displayed by the datagridview into a separate...
2
by: bob | last post by:
Can anyone tell me the best way to update a dataset while it is being edited/viewed in the DataGridView control? Is this something that should be inserted into one of the grid's events? or should...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
0
by: jeastman - Hotmail | last post by:
Hello world Excuse, not to be written English and it helps me with a translator. I am new programming in C#. I made a control inheriting the DataGridView to be able to add controls done by...
3
by: Andrus | last post by:
I have DataGridView in virtual mode containing 3500 rows. In code below, assigning to RowCount value to 3500 takes 8 seconds. CPU usage goes high at this time. Stepping by F11 into user code shows...
0
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.