Imports Infragistics.Win.UltraWinGrid
The way in which you access a particular row depends on the row, as well as the information you have about the row. The following procedure is an example of how to access rows in the WinGrid™ by traversing the WinGrid’s structure.
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;
In order to traverse the rows in the grid, you must get a reference to a row. Commonly, you will want to access the first row in the grid and work from there. You can do this with the GetRow method.
In Visual Basic:
Dim aRow As UltraGridRow aRow = UltraGrid1.GetRow(ChildRow.First)
In C#:
UltraGridRow aRow = this.ultraGrid1.GetRow(ChildRow.First);
Once you have access to the first row, you can use several methods to get references to other rows. If you want to get the next row in the same band, you would first check to see if there is a next row. To see if the row has a next sibling, you use the HasNextSibling Method.
In Visual Basic:
If aRow.HasNextSibling Then
In C#:
if(aRow.HasNextSibling()) {
Once it is established there is a next sibling, you can access it by using the GetSibling method of the row.
In Visual Basic:
Dim NextRow As UltraGridRow = aRow.GetSibling(SiblingRow.Next) MessageBox.Show("Has Siblings") Else MessageBox.Show("Has no Siblings") End If
In C#:
UltraGridRow NextRow = aRow.GetSibling(SiblingRow.Next); MessageBox.Show("Has Siblings"); } else MessageBox.Show("Has no Siblings");
In Visual Basic:
If aRow.HasChild Then Dim ChildRow As UltraGridRow = _ aRow.GetChild(Infragistics.Win.UltraWinGrid.ChildRow.First) MessageBox.Show("Has a Child") Else MessageBox.Show("Has no Child") End If
In C#:
if(aRow.HasChild()) { UltraGridRow childRow = aRow.GetChild(Infragistics.Win.UltraWinGrid.ChildRow.First); MessageBox.Show("Has a Child"); } else MessageBox.Show("Has no Child");