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.

Grid Row Deleting

Thread ID:

Created:

Updated:

Platform:

Replies:

27266 Apr 8,2005 09:36 AM Apr 8,2005 10:29 AM Windows Forms 1
loading
Tags: GridControl
Vinay
Asked On April 8, 2005 09:36 AM

Hi, We are currently facing a problem in deletion of rows. when the user select rows in sequence all the rows are deleted but if the user tags rows ( i.e select rows holding the ctrl key) only the last selected row gets deleted. Regards Vinay

Administrator [Syncfusion]
Replied On April 8, 2005 10:29 AM

There is special handling required to remove non-contiguous records. As soon as one record is removed, then this may effect the poition of the other records that are selected. The GridDataBoundGrid does not try to handle this. It just deletes the records in the ActiveRange. So if you want this behavior, then you would have to add support for this. You could do it in the RowsDeleting event.
private void grid_RowsDeleting(object sender, GridRowRangeEventArgs e)
{
	GridRangeInfoList rangeList = this.grid.Selections.GetSelectedRows(true, false);
	if(rangeList.Count > 0)
	{
		ArrayList a = new ArrayList();
		CurrencyManager cm = (CurrencyManager)this.grid.BindingContext[this.grid.DataSource, this.grid.DataMember];
		foreach(GridRangeInfo range in rangeList)
		{
			for(int row = range.Top; row <= range.Bottom; ++row)
			{
				int pos = this.grid.Binder.RowIndexToPosition(row);
				a.Add(-pos);
			}
		}
		a.Sort();
		foreach(int pos in a)
		{
			cm.List.RemoveAt(-pos);
		}
		e.Cancel = true;
	}
}

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.

;