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

Using GridGroupingControl as a listbox etc.

Hi, I would like to use two GridGroupingControls... one as a listbox, the second to contain the selected values. I do have the listbox grid selection mode working fine. My issue is with getting the selected values from the listbox grid into the selected values grid. The best way to accomplish this and meet my other requirements would be to copy the selected rows from the underlying DataTable in the listbox grid to the underlying DataTable in the selected values grid. I have found gridGroupingControl1.TableControl.Selections but I only see access to GridRangeInfo objects and not the selected rows. Do you have any examples of how to do this? Thanks in advance, Brian

1 Reply

AD Administrator Syncfusion Team October 5, 2004 03:34 PM UTC

Here is button handler that will create an arraylist of DataRowView objects from the selected rows.
private void button1_Click(object sender, System.EventArgs e)
{
	ArrayList drvs = new ArrayList();
	foreach(GridRangeInfo range in this.gridGroupingControl1.TableControl.Selections.Ranges)
	{
		if(range.IsRows)
		{
			for(int i = range.Top; i <= range.Bottom; ++i)
			{
				GridRecordRow rec = this.gridGroupingControl1.Table.DisplayElements[i]  as GridRecordRow;
				if(rec != null)
				 	drvs.Add(rec.GetData());
			}
		}
	}
	//now drvs should hold the select DataRowView objects
	foreach(DataRowView drv in drvs)
		Console.WriteLine(drv["Col1"]);
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon