質問

How can i expand the first row of a ultrawingrid which has the child row on load ? here is the way i want ultrawingrid to look like

in this ultrawingrid there are multiple rows which has child rows but i want to expand only first row which has child row like shown in picture. using C# .Net

I know that using expanAll methos i can expand all the rows.

Also i know that ExpandAncestors() will expand the row which i want(provided i need to select a row as child)

How can i achive this ? Thanks in Advance...

役に立ちましたか?

解決

I am not sure if there are better methods, but, as you know, the different levels of a UltraWinGrid are called Bands and a collection of this Bands is available in the DisplayLayout properties.

The idea is to enumerate the rows in the top level band and set the Expanded property to true after the setting of the DataSource only to the first row of this band.

// Returns a DataSet with two tables linked with a DataRelation
DataSet ds = GetDataSource;
grdMyData.DataSource = ds; 

// Now loop on the rows of the first band
foreach (UltraGridRow row in grdMyData.DisplayLayout.Bands[0].GetRowEnumerator(GridRowType.DataRow))
{
    // If the row has child rows, then set the its Expanded property 
    // to true and exits immediately the loop
    if (row.HasChild())
    {
        row.Expanded = true;
        break;
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top