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.
Unfortunately, activation email could not send to your email. Please try again.

How to get selected rows of a GridGroupingControl

Thread ID:

Created:

Updated:

Platform:

Replies:

50043 Oct 4,2006 06:04 AM Oct 5,2006 05:07 AM Windows Forms 3
loading
Tags: GridControl
Cuong Luc
Asked On October 4, 2006 06:04 AM

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.


Administrator [Syncfusion]
Replied On October 4, 2006 06:34 AM

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

Administrator [Syncfusion]
Replied On October 5, 2006 05:00 AM



>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.

Administrator [Syncfusion]
Replied On October 5, 2006 05:07 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;