Hi,
I'm trying to add child rows to a row but am getting a little confused as to how to go about it correctly. I'm currently using an UltraDataSource which has 1 childBand, I can add rows to the parent Band by simply using the UltraDataSource.Rows.Add() method but I can't see how to add rows to the child Band. Can anyone point me in the right direction??
Cheers,
Denis
Child rows in WinDataSource are contained underneath the rows that they're children of.
Your first step is to find the UltraDataRow object that your new UltraDataRow will appear underneath. From this, call the GetChildRows() method of that parent UltraDataRow, passing in the reference, string key, or index of the UltraDataBand to which your new row will belong - this is relevant if you have multiple bands at the same level. The method will return a collection of UltraDataRow objects, to which you can add your new row.
I'll follow up this post with an example momentarily.
So, say you have a WinDataSource with a few root-level rows, and you want to add a new row as the child of the second root-level row, underneath the band with the key "ChildBand". Here is the C# code I'd use for this:
using Infragistics.Win.UltraWinDataSource;...// Start with a reference to the row that serves as our parent rowUltraDataRow parentRow = ultraDataSource1.Rows[1];// Get a reference to the Rows collection that represents this row's child rows under the desired bandUltraDataRowsCollection childRows = parentRow.GetChildRows("ChildBand");// Add the row we want to addUltraDataRow newChildRow = childRows.Add();
Thanks i got it all worked out.
Dim parentRow As
UltraDataRow = dsoTot1.Rows(grdTot1.Rows.Count - 1)
Dim childRows As UltraDataRowsCollection = parentRow.GetChildRows("Total")
Dim newChildRow As UltraDataRow = childRows.Add()
newChildRow(
"Field") = "Green (Credit) Ticket Total"
"Value") = Credits
AllowAdd is a property, yet you're calling it as a method. Additionally, you're trying to add a row to a band, when you need to add a row to a collection of rows.
Here's a VB.NET translation of the C# code I previously provided:
*****Imports Infragistics.Win.UltraWinDataSource;...' Start with a reference to the row that serves as our parent rowDim parentRow as UltraDataRow = UltraDataSource1.Rows(1)' Get a reference to the Rows collection that represents this row's child rows under the desired bandDim childRows as UltraDataRowsCollection = parentRow.GetChildRows("ChildBand")' Add the row we want to addDim newChildRow as UltraDataRow = childRows.Add()*****
So is there a way you could show me this in VB?
I have tried this way so far but keep getting errors.
dsoTot1.Band.ChildBands("Total").AllowAdd(New ChildRow{"Green (Credit) Ticket Total", Credits})
I get the error "Property access must assign to the property or use its Value"
Brilliant, thanks a lot Vince!