Hi,
I want to remove all the rows in a wingrid. If I use grid.datasouce = nothing, the header in the grid would be also removed. So the time being, I can only do so by using a loop:
For each row as UltraGridRow in grid.rows
row.delete()
Next
Is there any more efficient way to do what I want? Thanks!
Tom
You shouln't set your datasource to NULL, that way, you remove the binding and you lose you datasource information used to determine the header.
Try setting your datasource to an empty objectlist, or, if you use datatable, set your datasource = datatable.Clone();
Yeah, you basically need to set the DataSource of the grid to a data source that has a stucture with no rows. If you don't care about the data in your data source, then you can probably clear all the rows fom the data source using a Clear method rather than looping and deleting one row at a time from the grid. But it depends on what you are using as your data source, of course.
Assuming that Tables(0) is the root table in your grid, then this works.
Dataset.Tables(0).Rows.Clear()
I just tested it out and the grid shows column headers with no rows.
I too am trying to clear the grid while keeping the column headers. I'm using a dataset for my datasource. None of the following causes anything to happen to the grid; Dataset.Clear, Dataset.Tables.Clear, Dataset.Tables(0).Clear, Dataset.Tables(0).Rows.Clear, etc. Adding any refresh method from the grid avails nothing (Grid.Refresh, Rows.Refresh(RefreshRow.FireInitializeRow, RefreshDisplay, ReloadData)). I've also tried Grid.Rows.Dispose...to no avail.