471,354 Members | 1,169 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 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 1240
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by DraguVaso | last post: by
10 posts views Thread by Henok Girma | last post: by
7 posts views Thread by Mitchell S. Honnert | last post: by
7 posts views Thread by =?Utf-8?B?TG9zdEluTUQ=?= | last post: by
reply views Thread by jeastman - Hotmail | last post: by
3 posts views Thread by Andrus | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.