Reset Grid

I have Grid.GridControl in which I've poplulated values, set formats etc. I'd like to reset the grid with entirely new values and different formats programmatically. I've tried a few things and could dispose of the control and add a new one, but is there a way to cleanly clear the grid and re-use the object that I've missed?

3 Replies

SH Stefan Hoenig Syncfusion Team July 11, 2002 12:12 AM UTC

> I have Grid.GridControl in which I've poplulated values, set formats etc. > > I'd like to reset the grid with entirely new values and different formats programmatically. > > I've tried a few things and could dispose of the control and add a new one, but is there a way to cleanly clear the grid and re-use the object that I've missed? > One easy way is to set row and column count to zero, as for example: gridControl1.RowCount = 0; gridControl1.ColCount = 0; After that set new row and column count and populate the grid. - Or - You simply attach a new data object: gridControl1.Data = new Syncfusion.Windows.Forms.Grid.GridData(); gridControl1.UpdateScrollBars(); Stefan Hoenig


SH Sam Horton July 11, 2002 10:07 AM UTC

> > I have Grid.GridControl in which I've poplulated values, set formats etc. > > > > I'd like to reset the grid with entirely new values and different formats programmatically. > > > > I've tried a few things and could dispose of the control and add a new one, but is there a way to cleanly clear the grid and re-use the object that I've missed? > > > > One easy way is to set row and column count to zero, as for example: > > gridControl1.RowCount = 0; > gridControl1.ColCount = 0; > > After that set new row and column count and populate the grid. > > - Or - > > You simply attach a new data object: > > gridControl1.Data = new Syncfusion.Windows.Forms.Grid.GridData(); > gridControl1.UpdateScrollBars(); > > Stefan Hoenig Thank you Stefan! I ended up having to clear a few things specific to the app as well to get the right behavior: Me.Grid.ReadOnly = False Me.Grid.Cols.RestoreFrozen() Me.Grid.ColCount = 0 Me.Grid.RowCount = 0 . . [re-populate] . Me.Grid.Refresh() What task does the command gridControl1.UpdateScrollBars() perform which helps the process? I'm curious....


SH Stefan Hoenig Syncfusion Team July 11, 2002 02:25 PM UTC

It just updates the scroll range information for the scrollbars and hides/shows scrollbars if necessary. This is necessary because when the data object is assigned, the view isnot refreshed and scrollbars would be out of sync. Stefan

Loader.
Up arrow icon