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

GridGroupingControl MultiExtend ListBoxSelectionMode

I am using a gridGroupingControl with the TableOptions.ListBoxSelectionMode set to MultiExtend. The behavior that I would like to see is that whenever a cell gets clicked on, the whole record will be selected. However it is not the case. About half the time when I click on a cell, only that cell gets selected (and not the whole row). However, if I click a second time on the cell, it will get selected. Is there a way to fix the behavior so the row gets selected on the first click, every time?

Thanks

5 Replies

MS Michael Sabin October 10, 2007 02:24 PM UTC

OK, i figured it out using the TableControlCurrentCellActivated event:

private void gridGroupingControl1_TableControlCurrentCellActivated(object sender, GridTableControlEventArgs e)
{
if (this.gridGroupingControl1.Table.CurrentRecord != null)
this.gridGroupingControl1.Table.SelectedRecords.Add(this.gridGroupingControl1.Table.CurrentRecord);
}


MS Michael Sabin October 10, 2007 08:02 PM UTC

I thought that it would work, but I guess there is other problems associated with it. It seems that sometimes I would end up with duplicate entries in the SelectedRecords collection.

I changed the logic to check if the record was in the SelectedRecords collection before I added it. However, now I run into the previous problem where the whole record does not get selected. It appears that the problem appears mostly with the Checkbox and TextBox cells in the grid.

Here is what I changed the code to:

///
/// Select the whole record when you click on a cell
///

private void gridGroupingControl1_TableControlCurrentCellActivated(object sender, GridTableControlEventArgs e)
{
if (this.gridGroupingControl1.Table.CurrentRecord != null)
{
Record rec = this.gridGroupingControl1.Table.CurrentRecord;
if (!this.gridGroupingControl1.Table.SelectedRecords.Contains(rec))
this.gridGroupingControl1.Table.SelectedRecords.Add(rec);
}
}


AD Administrator Syncfusion Team October 12, 2007 08:47 AM UTC

There are 2 kinds of selections available in a GridGroupingCOntrol, one specific to GridGroupingCOntrol that manages wholes records, and the other inherited from GridControlBase that might be rows, columns, cells, or whatever.

To get the record selections, try these setting:


//turn on the GridGroupingControl's listbox mode (uses Table.SelectRecords collection)
gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended; //turn
//turn off GridControlBase selection support (do not use TableControl.Selections collection
gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.None;
//indicate how you want current cell to look/behave
gridGroupingControl1.TableOptions.ListBoxSelectionCurrentCellOptions = GridListBoxSelectionCurrentCellOptions.HideCurrentCell;


MS Michael Sabin October 12, 2007 06:16 PM UTC

Thanks for the information, but unfortunately the HideCurrentCell option won't work for me. While it will accomplish what I want (I.E. the whole record gets selected on a click), it prevents the user from modifying the current cell. I.E. they can no longer edit TextBox fields and they can't check and uncheck CheckBox cells.

Thanks


GR Golda Rebecal Syncfusion Team October 24, 2007 11:21 AM UTC

Hi Michael,

HideCurrentCell option prevents the current cell from getting selected. That is why you are not able to edit the cell.

When ListBoxSelectionMode is set to MultiExtended and AllowSelection is set to None and ListBoxSelectionCurrentCellOptions property is 0not used, clicking on any cell selects the whole row but the current cell is selected and you can edit the current cell. If you want to edit the current cell and to have the color in the current cell same as the highlight color of the record, you have to use the following code.

this.gridGroupingControl1.TableOptions.ListBoxSelectionCurrentCellOptions = GridListBoxSelectionCurrentCellOptions.None;

Kindly let me know if this helps you.

Best regards,
Golda

Loader.
Live Chat Icon For mobile
Up arrow icon