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.
Unfortunately, activation email could not send to your email. Please try again.

Removing selected row with RemoveRange does not update RowCount

Thread ID:

Created:

Updated:

Platform:

Replies:

60730 May 10,2007 01:24 PM May 14,2007 07:56 PM Windows Forms 3
loading
Tags: GridControl
Michael Septimus
Asked On May 10, 2007 01:24 PM

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;

}


haneefm [Syncfusion]
Replied On May 10, 2007 02:26 PM

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

Michael Septimus
Replied On May 11, 2007 12:29 PM

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


haneefm [Syncfusion]
Replied On May 14, 2007 07:56 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;