In one of my controls, I am removing the selected row using RemoveRange. If the row is not the last row, it is removed. If it is the last row, it is cleared. But in any event the RowCount remains the same, so I am left with an empty row on the bottom.
I cluged this by checking the RowCount and decrementing it, if it remained the same - but this should not be necessary.
(De I have to de-select the row before deleting it?)
I have included a code snippet below:
else if (eventArgs.Action == WatchList.WatchListActionEnum.Delete)
{
int row = eventArgs.RowIndex;
Debug.Assert(row < _gridControl.RowCount);
int oldRowCount = _gridControl.RowCount;
_gridControl.Rows.RemoveRange(row + 1, row + 1);
_gridControl.Update();
if (_gridControl.RowCount == oldRowCount)
_gridControl.RowCount = oldRowCount - 1;
}
HA
haneefm
Syncfusion Team
May 10, 2007 06:26 PM UTC
Hi Michael,
Instead of calling the Update method, you can try calling the Refresh method in a grid and let me know if this helps.
else if (eventArgs.Action == WatchList.WatchListActionEnum.Delete)
{
int row = eventArgs.RowIndex;
Debug.Assert(row < _gridControl.RowCount);
int oldRowCount = _gridControl.RowCount;
_gridControl.Rows.RemoveRange(row + 1, row + 1);
_gridControl.Refresh();
if (_gridControl.RowCount == oldRowCount)
_gridControl.RowCount = oldRowCount - 1;
}
Best regards,
Haneef
MS
Michael Septimus
May 11, 2007 04:29 PM UTC
Haneef,
Refresh works!
Thank you.
Now perhaps you can explain what the grid does on Refresh and what it does on Update? I am unclear about that.
Also, does Refresh cause the entire sheet to repaint?
Thanks,
Michael
>Hi Michael,
Instead of calling the Update method, you can try calling the Refresh method in a grid and let me know if this helps.
else if (eventArgs.Action == WatchList.WatchListActionEnum.Delete)
{
int row = eventArgs.RowIndex;
Debug.Assert(row < _gridControl.RowCount);
int oldRowCount = _gridControl.RowCount;
_gridControl.Rows.RemoveRange(row + 1, row + 1);
_gridControl.Refresh();
if (_gridControl.RowCount == oldRowCount)
_gridControl.RowCount = oldRowCount - 1;
}
Best regards,
Haneef
HA
haneefm
Syncfusion Team
May 14, 2007 11:56 PM UTC
Hi Michael,
Refresh is a method from the .NET Windows Forms Control class. It simply invalidates the client area and forces the control to redraw itself and it child controls. When you call the Refresh method, It triggers the QueryXXX events like QueryCellInfo, QueryColcount, QueryRowCount, etc.
Update is also a method from the .NET Windows Forms Control class. It causes the control to redraw the invalidated regarionds within its client area.
Best regards,
Haneef