Yeah I know the title sounds funny. It is, but like kids they are going to make me crazy.
Ok here is the stiuation. I need to get the transactiontableid datavalue if it is changed (band 2) then the elementid displaytext (band 1?) and the AllocatorID (band 2 child 1?) and then change the value list in RuleName (band 2 child 1 child 1?). The valuelist for RuleName would also be changed for all allocatordetail childs in such manner. I have tried Parent, Selected row and nothing is working. Please help and thank you....
url for full image is http://www.kjmsolutions.com/images/gridconfusion.jpg
If you're trying to do this in something like CellChange or AfterCellUpdate, then you should have a reference to the TransactionTableID cell. You can get this value, then look at the ParentRow.ChildBands[ElementDetailKey].Rows[0] for the ElementID (you might wan to look at the Text property of the cell). To get the AllocatorID, it looks like it's just the first child row, so you'd have row.ChildBands[0].Rows[0].Cells["AllocatorID"]. Similarly to get at the RuleName, you'd look at the child row in the same way off of the AllocatorDetail row.
Were there additional parts of this that were giving you trouble? I'm not sure that I fully understood when you are trying to do this and which problems you were facing.
-Matt
Ok lets start iwth that. How can I capture the datavalue of the transacitontableId once it is changed? Wouldn't the cell update event fire for everything if I do that?
It appears to have worked. I had a stoppoint in there i had forgot to take out. Thank you for your help.
Correction: It works on the first row where the transactionid is but on a second or third row. What am I missing?
How it stands now:
If e.Cell.Column.Key <> "TransactionTableID" Then
Exit Sub
End If
ElementID = dgElements.Rows(dgElements.ActiveRow.GetChild(0).Index).Cells(0).Value
trantableid = dgElements.ActiveRow.Cells("TransactionTableID").Value
Debug.WriteLine(dgElements.ActiveRow.ChildBands(0).Rows.Count - 1)
allocatorid = dgElements.ActiveRow.ChildBands(0).Rows(0).Cells("AllocatorID").Value
"sqlstatement"
RulesList.ValueListItems.Clear()
Dim i As Integer
RulesList.ValueListItems.Add(dt.Rows(i).Item("RuleID"), dt.Rows(i).Item("RuleName"))
Next
Dim ii As Integer
dgElements.ActiveRow.ChildBands(0).Rows(0).ChildBands(i).Rows(ii).Cells("RuleName").ValueList = RulesList
End Sub
The problem here is that you're indexing directly into the Rows collection of the main grid, so you're always going to get a row off of the main band. I would think that you would have something like:
ElementID = e.Cell.Row.ParentRow.Cells(0).Value
trantableid = e.Cell.Value ' Since this is what we're checking to see if it changed at the beginning
allocatorid = e.Cell.Row.ChildBands(0).Rows(0).Cells("AllocatorID").Value
While I think that the ActiveRow would still work, I think it's preferable to use the guaranteed reference to the cell/row that is provided to you via this method. If somehow the TransactionTableID cell gets changed without the row being active (i.e. in code), the code you've written will fail.
OK I get an index is outside the bounds of the array on the second row of the TransactionTableID still. I have reflected your changes in the code. The error occurs at AllocatorID assignment.
allocatorid = e.Cell.Row.ChildBands(0).Rows(0).Cells("AllocatorID").Value 'Error index outside of array
'ElementID = dgElements.Rows(dgElements.ActiveRow.GetChild(0).Index).Cells(0).Value
' trantableid = dgElements.ActiveRow.Cells("TransactionTableID").Value
'Debug.WriteLine(dgElements.ActiveRow.ChildBands(1).Rows.Count - 1)
'allocatorid = dgElements.ActiveRow.ChildBands(dgElements.ActiveRow.GetChild(0).Index).Rows(0).Cells("AllocatorID").Value
"slfunction"
For i = 0 To e.Cell.Row.ChildBands(0).Rows(0).ChildBands.Count - 1 'dgElements.ActiveRow.ChildBands(0).Rows(0).ChildBands.Count - 1
It seems as same as before. The top row in Allocator will work fine if I change the transactiontableid. The second row in Allocator fails on the assignment of allocatorid.
Added Note: It appears to think there are -1 rows present in this child though that is not the case here. This happens in any row that is not the first row of Allocators.
Assuming that the order of the child bands don't change (and thus a row from a different band is returned from the FirstRow property), I don't really see a problem with the code. I don't know why you need to set the ActiveRow, but I don't necessarily see the harm in this either since it may become the active row anyway when the user expands it.
Okay this seems to work. Please review and tell me what you think or if you think I need to make changes. This has been very educational for me. Thank you for your patience though this.
Private Sub dgElements_AfterRowExpanded(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.RowEventArgs) Handles dgElements.AfterRowExpanded
dgElements.ActiveRow = e.Row
Dim itexists As Boolean
If dgElements.ActiveRow.Cells(i).Column.Key = "TransactionTableID" Then
itexists = True
Exit For
Else
itexists = False
If itexists = True Then
ElementID = dgElements.ActiveRow.ParentRow.Cells(0).Value
trantableid = dgElements.ActiveRow.Cells("TransactionTableID").Value ' Since this is what we're checking to see if it changed at the beginning
allocatorid = dgElements.ActiveRow.ChildBands.FirstRow.Cells("AllocatorID").Value
Dim strSQL As String ="sqlstuff"
For i = 0 To dgElements.ActiveRow.ChildBands.FirstRow.ChildBands.Count - 1 'dgElements.ActiveRow.ChildBands(0).Rows(0).ChildBands.Count - 1
dgElements.ActiveRow.ChildBands.FirstRow.ChildBands(i).Rows(ii).Cells("RuleName").ValueList = RulesList
The event args should still give you a handle to the row, so I don't see why you couldn't just replace the row that you got in AfterCellUpdate with this row instead.
Ok now they threw this at me. They want it done when they click the + sign on the row to have it do it for all the valuelists.....can I use the previously written code even though no cell is selected?
Is the only change the use of FirstRow? This method will walk over all of the child bands until it finds a row, so the row you're looking for might not actually be ChildBands(0). Regardless, glad it's working for you.