We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Removing Cells (or the appearance of it)

What Does GridControl.ClearCells( GridRangeInfo, bool) do? What does the 'bool' arg specify? The docs are not clear on this. I have a grid that starts out with 4 rows, 10 cols and the default cell type (TextBox?). I populate the grid by changing the CellType to PushButton and setting the Description field. When the user presses a cell I want to give the appearance of the cell contents being removed and the other cells shifting over to replace what was there. There does not seem to be an easy way to do this. I was hoping to be able to do the following: Assume a 1 Row x 4 Col grid. User selects 1,3. grid[1,3] = grid[1,4]; grid.ClearCells(GridRangeInfo.Cell(1,4),TrueOrFalseWhateverWorks); There must be a better way... does the cell assignment statement in the above pseudocode 'do the right thing'? The Grid.PopulateValues() was enticing, but each value from my array occupied a row instead of a cell, so I've resorted to using iteration.

1 Reply

SH Stefan Hoenig Syncfusion Team July 18, 2002 08:52 PM UTC

Hi Roy, the Boolean flag indicates if only text content shall be cleared out or if all cell content information including color, cell type and other appearance information should be cleared. ClearCells does not shift cells. I agree that is something we should add (something like a MoveCells method) and we'll look into that. What you can do now is use a combination of GetCells, SetCells and Clear to shift cells: private void button1_Click(object sender, System.EventArgs e) { int top = 3; int bottom = 10; int colCount = this.gridControl1.ColCount; GridRangeInfo source = GridRangeInfo.Cells(top,4,bottom,colCount); GridRangeInfo target = GridRangeInfo.Cells(top,2,bottom,2+source.Width-1); GridRangeInfo clear = GridRangeInfo.Cells(top,target.Right+1,bottom,colCount); GridStyleInfoStoreTable cells = this.gridControl1.GetCells(source); this.gridControl1.BeginUpdate(); this.gridControl1.SetCells(target, cells); this.gridControl1.ClearCells(clear, true); this.gridControl1.EndUpdate(false); this.gridControl1.Refresh(); } } I attached a sample project. Stefan Hoenig

Loader.
Up arrow icon