Home All Groups Group Topic Archive Search About

.NET 2.0 DataGridView

Author
15 Feb 2006 8:58 PM
dm1608
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

Author
15 Feb 2006 9:02 PM
Nicholas Paldino [.NET/C# MVP]
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]
          - mvp@spam.guard.caspershouse.com

Show quoteHide quote
"dm1608" <dm1608@spam.net> wrote in message
news:%23kJPNKnMGHA.1760@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
>
>
>
Author
15 Feb 2006 9:37 PM
dm1608
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(ApplicationsDataGridView.Rows(i))
   Next
End If


Show quoteHide quote
"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in
message news:e4lKJMnMGHA.1028@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]
>          - mvp@spam.guard.caspershouse.com
>
> "dm1608" <dm1608@spam.net> wrote in message
> news:%23kJPNKnMGHA.1760@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
>>
>>
>>
>
>
Author
16 Feb 2006 8:20 AM
Jason Myers
Have u tried setting the RowCount Property to 0?

Show quoteHide quote
"dm1608" <dm1608@spam.net> wrote in message
news:%23kJPNKnMGHA.1760@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
>
>
>