RaymondC
  • RaymondC
  • Advanced Member Topic Starter
2015-04-17T20:16:03Z
I often hide child rows and then need to loop through all the children to see if at least one is still visible so I can decide whether or not to hide the parent group row.

A RowHasVisibleChildren property (similar to RowHasChildren) would be very helpful.
Igor/10Tec
2015-04-20T08:43:49Z
There are many scenarios when we need functions like this. We decided not to bloat the control by implementing all these functions as they can be easily coded using the existing basic members like RowLevel.

Below is one of possible implementations of the RowHasVisibleChildren function that can be used as a basis to implement similar functionality:

Private Function RowHasVisibleChildren(ByVal poGrid As iGrid, ByVal plRow As Long) As Boolean
   Dim iRow As Long
   Dim btLevel As Byte
   
   btLevel = poGrid.RowLevel(plRow)
   
   iRow = plRow + 1
   Do While iRow <= poGrid.RowCount
      Select Case poGrid.RowLevel(iRow)
      Case Is <= btLevel
         ' No more children
         RowHasVisibleChildren = False
         Exit Function
      Case btLevel + 1
         ' A child row of the specified row
         If poGrid.RowVisible(iRow) Then
            RowHasVisibleChildren = True
            Exit Function
         End If
      End Select
      
      ' Next row
      iRow = iRow + 1
   Loop
   
   RowHasVisibleChildren = False
End Function

An example of calling that detects whether the 3rd row of iGrid1 has visible child rows:

Debug.Print RowHasVisibleChildren(iGrid1, 3)