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. Image for the cookie policy date

Mutile Selections ComboBox

I have a DataBoundGrid with a ComboBox column and I would like the user to be able to select mutiple rows then when they change the option in the combo box in one of the selected rows, all of the other selected rows change their options to match. That would save my users a lot of hassle. Could you give me any pointers please? Thanks, Mark

3 Replies

AD Administrator Syncfusion Team June 7, 2004 02:59 AM

You can try doing this in the CurrentCellChanged event.
private void gridDataBoundGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(cc.ColIndex == 2) //id combo column somehow
	{
		GridRangeInfo range = this.gridDataBoundGrid1.Selections.Ranges.ActiveRange;
		if(!range.IsEmpty && range.Contains(cc.RangeInfo))
		{
			range = range.IntersectRange(GridRangeInfo.Col(cc.ColIndex));
			cc.ConfirmChanges(true);
			int position = this.gridDataBoundGrid1.Binder.CurrentPosition;
			this.gridDataBoundGrid1.Model.ChangeCells(range, cc.Renderer.ControlText);
			this.gridDataBoundGrid1.Binder.SetCurrentPosition(position, true);
		}
	}
}


AD Administrator Syncfusion Team June 8, 2004 09:19 AM

Thanks Clay, that worked a treat. The code works great for block selections i.e. rows 1 though 6 but is there a way to expand the code to work for disjointed selections ie. selected rows 1,4,8,33 when the user selects via control+click. Is there a way to loop through the selected ranges in turn? Thanks, Mark


AD Administrator Syncfusion Team June 8, 2004 09:53 AM

Instead of GridRangeInfo range = this.gridDataBoundGrid1.Selections.Ranges.ActiveRange; that only looks at the active range, you could try the same code in this type of loop foreach(GridRangeInfo range in this.gridDataBoundGrid1.Selections.Ranges) { //same code }

Loader.
Live Chat Icon For mobile
Up arrow icon