Hi,
I''ve searched alot but couldn''t find out how to get the selected rows in a GridGroupingControl (I use AllowSelection = GridSelectionFlags.Any to allow user to select multi rows).
I''ve tried with gridGroupingControl.Table.SelectedRecords but it was empty although I have some selected rows in the grid.
Please help me with this.
Thanks and regards.
AD
Administrator
Syncfusion Team
October 4, 2006 10:34 AM UTC
Hi Cuong,
Use the Model.Selections property to manages selected ranges in the grid. It allows you to add, remove and get selections, determines selection state of a specific cell.
//Get the selected rows from the groupin grid.
GridRangeInfoList range = this.gridGroupingControl1.TableModel.Selections.GetSelectedRows(true,true);
foreach( GridRangeInfo info in range)
{
Element el = this.gridGroupingControl1.TableModel.GetDisplayElementAt(info.Top);
Console.WriteLine( "Selected RowIndex : " + info.Top + " =====> " + el );
}
Thanks,
Haneef
AD
Administrator
Syncfusion Team
October 5, 2006 09:00 AM UTC
>Hi Cuong,
Use the Model.Selections property to manages selected ranges in the grid. It allows you to add, remove and get selections, determines selection state of a specific cell.
//Get the selected rows from the groupin grid.
GridRangeInfoList range = this.gridGroupingControl1.TableModel.Selections.GetSelectedRows(true,true);
foreach( GridRangeInfo info in range)
{
Element el = this.gridGroupingControl1.TableModel.GetDisplayElementAt(info.Top);
Console.WriteLine( "Selected RowIndex : " + info.Top + " =====> " + el );
}
Thanks,
Haneef
Thank you so much, Haneef. You''ve helped me to solve it. The grid is quite nice :).
One more thing, does GridGroupingControl have a property to set the last column always fill the remaing space of the form (like FillLastColumn property of GridListControl)?
Regards,
Cuong Luc.
AD
Administrator
Syncfusion Team
October 5, 2006 09:07 AM UTC
Hi Cuong,
There is no built-in support for this. But you can handle the TableModel.QueryColWidth event and set the width of the last column. Below is a code snippet.
private void TableModel_QueryColWidth(object sender, GridRowColSizeEventArgs e)
{
GridTableModel model = sender as GridTableModel;
int findex = model.Table.TableDescriptor.VisibleColumns.Count - 1;
int index = model.FieldToColIndex( findex);
if(e.Index == index )
{
int cwidth = this.gridGroupingControl1.ClientSize.Width;
int twidth = model.ColWidths.GetTotal(0,e.Index-1);
e.Size = cwidth - twidth;
e.Handled = true;
}
}
Let us know if this helps.
Best Regards,
Haneef