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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Expanding selected rows in a GDBG

Thread ID:

Created:

Updated:

Platform:

Replies:

55201 Jan 24,2007 11:17 PM UTC Jan 25,2007 08:23 PM UTC WinForms 5
loading
Tags: GridControl
Nick M
Asked On January 24, 2007 11:17 PM UTC

I am attempting to expand rows selected in a hierarchical GDBG. I only want to expand selected rows.

I tried looping thru the GridDataBoundGrid.Selections collection and using the ExpandRowAtIndex API, but if I expand more than one row, a 'Collection Modified' exception is thrown. I am assuming this is because the number of rows changes?

Any ideas on how to tackle this?

Thanks,
Nick

Administrator [Syncfusion]
Replied On January 24, 2007 11:51 PM UTC

Hi Nick,

Here is a code snippet that sshows you How to expand the selected row in a GridDataBoundGrid.

GridRangeInfoList selectedRangeList = new GridRangeInfoList();
this.gridDataBoundGrid1.Model.SelectedRanges.CopyTo(selectedRangeList,0);
foreach(GridRangeInfo info in selectedRangeList )
{
for(int i = info.Top; i<=info.Bottom ; i++)
{
GridBoundRecordState rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(i);
bool haslist = rs.HasChildList;
if(haslist)
{
bool isExpand = this.gridDataBoundGrid1.IsExpandedAtRowIndex(i);
if( !isExpand )
this.gridDataBoundGrid1.ExpandAtRowIndex(i);
}
}
}

Please refer to the attached sample for implementation.
SelectedRowExpand.zip

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On January 24, 2007 11:55 PM UTC

Thanks for the quick response. I'll try this.

Thanks Haneef


Nick

Administrator [Syncfusion]
Replied On January 25, 2007 07:24 PM UTC

This works well, except in the case where only one row is selected. SelectedRanges only seems to be valid if more than 1 row is selected. I haven't been able to find a 'SelectedRow' or 'SelectedCell' member that would work with the above solution in the case of only a single row being selected.

Any ideas?

Thanks,
Nick

Administrator [Syncfusion]
Replied On January 25, 2007 07:44 PM UTC

Never mind, I figured it out. Using:

this.gridDataBoundGrid1.ListBoxSelectionMode = SelectionMode.MultiExtended; //Set the SelectionMode.

did the trick

Thanks!

>This works well, except in the case where only one row is selected. SelectedRanges only seems to be valid if more than 1 row is selected. I haven't been able to find a 'SelectedRow' or 'SelectedCell' member that would work with the above solution in the case of only a single row being selected.

Any ideas?

Thanks,
Nick

Administrator [Syncfusion]
Replied On January 25, 2007 08:23 PM UTC

Hi Nick,

If you are not selecting multiple cells, then SelecteRanges will not return anything. You need to use another method, GetSelectedRanges. See this KB.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=280

Here is a code snippet to expanding selected record using GetSelectedRanges method.

GridRangeInfoList selectedRangeList = new GridRangeInfoList();
this.gridDataBoundGrid1.Model.Selections.GetSelectedRanges(out selectedRangeList,true);
foreach(GridRangeInfo info in selectedRangeList)
{
for(int i = info.Top; i<=info.Bottom ; i++)
{
GridBoundRecordState rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(i);
bool haslist = rs.HasChildList;
if(haslist)
{
bool isExpand = this.gridDataBoundGrid1.IsExpandedAtRowIndex(i);
if( !isExpand )
this.gridDataBoundGrid1.ExpandAtRowIndex(i);
}
}
}

Sample : ModifiedSelectedRowExpand.zip

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.

Warning Icon 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.Close Icon

;