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.

Deleting the last item of a DataboundGrid

Thread ID:





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

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 07:46 AM

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