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.
Syncfusion Feedback

Deleting the last item of a DataboundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

2994 Feb 25,2003 12:43 AM UTC Feb 25,2003 12:46 PM UTC Windows Forms 1
loading
Tags: GridControl
Sue Harris
Asked On February 25, 2003 12:43 AM UTC

Hi, I've got a DataboundGrid which I bind to an ArrayList. I've got a button which deletes the currently selected row (using DeleteRecordsAtRowIndex, or deleting from the ArrayList and rebinding). If the row being deleted is the last row in the grid, I always get a System.ArgumentOutOfRangeException when I try to select another row. I'm guessing the problem is the models selected index, or current cell. Is this a bug? Or is it part of my responsibilities to check when I delete or rebind that the current cell / selection is valid? Thanks, Sue

Administrator [Syncfusion]
Replied On February 25, 2003 12:46 PM UTC

We will look into this. It sounds like something that should not happen. Here is a work-around that avoids the problem until we get it fixed.
private void button1_Click(object sender, System.EventArgs e)
{
	int row = this.gridDataBoundGrid1.Binder.PositionToRowIndex(this.gridDataBoundGrid1.Binder.CurrentPosition);;
	if(row == this.gridDataBoundGrid1.Model.RowCount && row > 0)
	{
		this.gridDataBoundGrid1.CurrentCell.MoveUp(1, false);
	}
	this.gridDataBoundGrid1.DeleteRecordsAtRowIndex(row,row);
}

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.

Warning Icon 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.Close Icon

;