Imports Infragistics.Win.UltraWinGrid
Sometimes when you write code to traverse the WinGrid™, it is necessary to know the number of child bands of a particular band. The WinGrid control provides this information through the ChildBands property of the Band object.
Before you start writing any code, you should place using/imports directives in your code-behind so you don’t need to always type out a member’s fully qualified name.
In Visual Basic:
Imports Infragistics.Win.UltraWinGrid
In C#:
using Infragistics.Win.UltraWinGrid;
Declare a function called GetNumberOfChildBands. This function will accept a Band object and return the number of child bands.
In Visual Basic:
Private Function GetNumberOfChildBands(ByVal aBand As _ Infragistics.Win.UltraWinGrid.UltraGridBand) As Integer
In C#:
private int GetNumberofChildBands(Infragistics.Win.UltraWinGrid.UltraGridBand aBand) {
A band object is actually a special type of column. You can take advantage of this by looping through the columns in the band. Set up a For…Each Loop to go through the columns in the Band that was passed into the Function.
In Visual Basic:
Dim aCol As UltraGridColumn For Each aCol In aBand.Columns
In C#:
int GetNumberofChildBands = 0; foreach(UltraGridColumn aCol in aBand.Columns) {
You can now check each column one at a time and determine if it is a Band.
In Visual Basic:
If aCol.IsChaptered Then
In C#:
if(aCol.IsChaptered)
If the column is a band, add one to the return value of the function.
In Visual Basic:
GetNumberOfChildBands = GetNumberOfChildBands + 1 End If
In C#:
GetNumberofChildBands = GetNumberofChildBands + 1; }
Then just close the loop.
In Visual Basic:
Next aCol
In C#:
return GetNumberofChildBands; }