Select checkboxes on many lines in grid

Users would like to be able to select a block of lines in a grid like PO Suggestions and select all the “Buy” checkboxes with a single click.

Anyone had this request before an know of a way to set the Buy flag for a highlighted group of suggestions?

Thanks!

Paul

That sounds tricky. My first attempt at something like this would be to determine if the Grid control actually knows which rows are “highlighted”. Without that info, I don’t know how any other code or process would know which rows of the dataview need that checkbox field updated.

True; the more I am thinking about this, I don’t even know if this is standard windows functionality?

Just started doing some testing and it looks like it might not be that hard. At the moment, I have a button that when pressed, will tell you how many rows of a specific grid are selected

The code for that is:

	private void btnUpdateTest_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		// get reference to the desired grid
		EpiUltraGrid grd = (EpiUltraGrid)csm.GetNativeControlReference("bec51417-b286-4d61-a471-3912bc098905");

		Selected grdSelection = grd.Selected;
		SelectedRowsCollection grdRows = grdSelection.Rows;
		int rowCount = grdRows.Count;
		int i;
		StringBuilder msg = new StringBuilder("", 500);

		msg.AppendFormat("Row Count: {0}", rowCount.ToString());
		for(i = 0; i< rowCount; i++)
			{
			// loop through the selected rows to determine which dataview rows need updating
			}
		EpiMessageBox.Show(msg.ToString());
	}

Hm so if you can count the number of selected you could possibly change a field using the selected state?

The

SelectedRowsCollection grdRows

from Calvin’s example will give a collection of selected rows(pretty reliable in my exp.). You can loop over this collection of rows and use the current selected row’s index(in the overall collection) to do something(like set buy to true).
One option would be an event handler that listens when the buy value changes for a single row(the users clicks it). In the handler, loop over all selected rows and select buy for them as well.
Alternately, you could add a button(named something like ‘Buy Selected’ and handle the click event of the button and loop over the selected rows and… yada yada.

You can loop through the all rows using a foreach, and if selected (it’s a property on the row) check the box on the current row. I’ve done it many times.