The help document of Infragistics 7.3 says "If the current ActiveRow does not provide enough context, then an error is thrown. ActiveRow needs to be on a sibling band or a parent band. "code 1:For bandcount As Integer = 0 To 2 .DisplayLayout.Bands(bandcount).Override.AllowAddNew = AllowAddNew.YesNext bandcount.DisplayLayout.Bands(X).AddNew()
code 2:For bandcount As Integer = 0 To 2 .DisplayLayout.Bands(bandcount).Override.AllowAddNew = AllowAddNew.YesNext bandcountIf .Selected.Rows(0).HasParent Then .Selected.Rows(0).ParentRow.Activate() .Selected.Rows(0).ParentRow.Selected = TrueElse .Selected.Rows(0).Activate()End If.DisplayLayout.Bands(X).AddNew()
The "AddNew()" method works fine when x=0 but error when x=1 or 2.Why?
Hi,
I'm not sure what you are trying to do here, but this code doesn't make a lot of sense. Adding a row to the root-level of the grid is fine. But when you add a row to a child level, the grid needs some sort of context. It needs to know to what parent row you are adding a child row. The way you have this code set up, even if it worked, you would essentially be adding an empty row to the root level and then an empty row as the child of the first row and then another empty row as a child fo the first child row.
It looks to me like you are trying to simulate having an add row show up on each island of data. But you don't have to simulate this, you can do it by setting AllowAddNew to TemplateOnBottom.
And by the way, you don't need to loop through the bands and do this on each one, you can do it on the grid.DisplayLayout.Override to apply this setting to all bands.
Hey Mike - I want to add a child row manually right now, just for a demo. Is there a better example of how to do it than this?
If you just want to set up your grid with some empty row, it would probably be a lot easier to add the rows to your data source, rather then through the grid. To do it through the grid, you will probably need to update the ActiveRow in the grid each time you want to add a row. For example, if you want to add a child row under the 2nd parent row, you would need to make the parent row active before calling AddNew.