Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
Unable to display the ChildRows in UltraGrid
posted

The UltraDataSource is created by code as below. The datasource then is assigned to a UltraGrid. But the grid only display the rows in Band 0, the rows in child band can't be viewed in the application. Can someone help with this?

Thank you!!!

 

//Define the datasource
Infragistics.Win.UltraWinDataSource.UltraDataSource ds = new UltraDataSource();

string[ columnNames = new string[{"col1", "col2", "col3"};
string[ columnTypes = new string[{"System.String", "System.String", "System.String"};
string[ childColNames = new string[{"SubCol1", "SubCol2","SubCol3"};

for (int i = 0; i < columnNames.Length; i++)
{  
  
   string type = columnTypes[i];
      ds.Band.Columns.Add(columnNames[i],
Type.GetType(type));
}
ds.Band.ChildBands.Add(
"ChildBand");

for (int i = 0; i < childColNames.Length; i++)
{
   
string type = columnTypes[i];
    ds.Band.ChildBands[0].Columns.Add(childColNames[i],
Type.GetType(type));
}

//populate data
object[  row1 = new object[  {"1", "2", "3"};
UltraDataRow row11 = ds.Rows.Add(row1);
row11.GetChildRows[0].Add(row1);

UltraGrid grid  = new UltraGrid();

grid.DataSource = ds;

Parents
No Data
Reply
  • 469350
    Offline posted

    I tested this code out and it appears to work fine for me. I had to make some small modificatios to get it to complie, though.

    First, I had to change:

    row11.GetChildRows[0].Add(row1);

    to 

    row11.GetChildRows(0).Add(row1);

    I assume that must be a typo in your post. 

    The only other thing I did was I put a grid on the form at design-time instead of creating the grid in code. The code you have here just creates the grid in code and it is never displayed or parented to any form, so it's impossible to know if it worked or not. 

Children
No Data