Accessing Grid Elements in Infragistics UltraGrid

Applies to TestComplete 15.68, last modified on October 03, 2024

To perform any operation over the grid you will need to obtain the corresponding object. This topic names the main elements of the Infragistics UltraGrid control and describes how to retrieve them in scripts. The topic contains the following sections:

To perform these actions, TestComplete should have access to internal objects, properties and methods of the UltraGrid control. For this purpose, the .NET Application Support plugin must be installed and enabled.

When testing Infragistics UltraGrid controls, use specific methods and properties of the corresponding Infragistics UltraGrid object. You can call these methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with an object’s properties and methods from your scripts. However, when testing a UltraGrid control from your keyword test, you can use the same methods and properties calling them from keyword test operations. For more information, see Keyword Tests Basic Operations.

Basic Concepts

The Infragistics UltraGrid can contain data from one or several data sets, at that, it can be organized either as a single data view or as a series of hierarchical data views. A band or data view defines the representation of data rows from the same dataset and also defines the behavior of the dataset. In Infragistics, they also use the term band to denote a data view, since it often has a banded form. To display hierarchical data (for example, master-detail relationship) UltraGrid uses several data views.

In the view, the data is organized by rows and by columns. A row represents a single data entity that is contained in an underlying dataset. Columns determine the information that characterizes a data entity. Generally columns have headers that name (or describe) the corresponding data set value.

For every element of a grid Infragistics UltraGrid control provides a special internal object. These objects have methods and properties that allow you to access the underlying data. The table below lists the main elements and internal objects that correspond to them.

Grid Element Description Object Name
Grid An object that represents the grid. UltraGrid
Data View, Band An object that represents a set of related columns of data that belong to the same hierarchical level. UltraGridChildBand
Row Represents a row from the attached data source. UltraGridRow
Column An object that represents a single column of data. UltraGridColumn
Cell This class represents a specific column in a specific row. UltraGridCell
Note: These objects are accessible through native properties exposed by the .NET Application Support plugin.

Each high-level element of a grid (grid, band, row and others) has a number or properties that provide access to the child elements belonging to the element. Generally, these properties return a collection of objects that enumerate the child elements. Using the collection’s methods and properties you can retrieve the individual child element.

Accessing the Grid

To retrieve an object that corresponds to a control, your application must be “open” to TestComplete. Infragistics UltraGrid control is designed for .NET applications that are fully open to TestComplete. That is you can use any internal objects, methods and properties of .NET applications without any preliminary preparation. Therefore, to get the grid control you can use the WinFormsObject method of the Process or of the Window object, depending on where the control is placed. To make sure that you have obtained the grid, you can check the ClrClassName property - it should be UltraGrid.

Moreover, TestComplete has a special scripting object called InfragisticsUltraGrid. It has the properties and actions that are required to interact with the Infragistics Win Grid control. TestComplete recognizes the grid during script recording and transforms mouse actions over it to corresponding actions of the InfragisticsUltraGrid object.

Accessing Data of Grid Elements

Any grid object has at least one data view - it is the grid itself. Because of this, the grid has all the methods and properties that are specific to a data view. Each row of a grid or data view can have one or several child data views. They are used to represent data from the datasets of a lower hierarchy level that concerns the parent row.

There are two ways to obtain a data view of a grid or another data view. The first is to use the property wChildView that is provided by TestComplete. The second approach utilizes the internal properties of a grid control, this approach is quite complicated, however it returns the UltraGridChildBand object that provides more information.

Using TestComplete extended properties and objects

To represent a data view of an Infragistics UltraGrid control, TestComplete has a special InfragisticsUltraGridView object. To find out the number of child data views of a certain row you can read the wChildViewCount property. To retrieve a child data view use the wChildView property.

The following example shows how to access the value of the desired cell for one of the child grid views:

JavaScript, JScript

function Main()
{
  var p;
  var w1, w2;
  var Grid, ChildView, CellValue;

  // Obtain the application process and its main form
  p = Sys.Process("SamplesExplorer");
  w1 = p.frmMain.WinFormsObject("tvwSamples");
  // Open the 'Merged Cells Feature' demo
  w1.DblClickItem("|Feature Samples|V5.1 Merged Cells Feature");
  w2 = p.frmMergedCells;
  
  // Obtain the grid control
  Grid = w2.WinFormsObject("UltraGrid1");
  // Obtain the child data view of a third row
  ChildView = Grid.wChildView(2);
  // Obtain the cell value
  CellValue = ChildView.wValue(0, "Data");
}

Python

def Main():

  # Obtain the application process and its main form
  p = Sys.Process("SamplesExplorer")
  w1 = p.frmMain.WinFormsObject("tvwSamples")
  # Open the 'Merged Cells Feature' demo
  w1.DblClickItem("|Feature Samples|V5.1 Merged Cells Feature")
  w2 = p.frmMergedCells
  
  # Obtain the grid control
  Grid = w2.WinFormsObject("UltraGrid1")
  # Obtain the child data view of a third row 
  ChildView = Grid.wChildView[2]
  # Obtain the cell value
  CellValue = ChildView.wValue(0, "Data")

VBScript

Sub Main
  Dim p
  Dim w1, w2
  Dim Grid, ChildView, CellValue

  ' Obtain the application process and its main form
  Set p = Sys.Process("SamplesExplorer")
  Set w1 = p.frmMain.WinFormsObject("tvwSamples")
  ' Open the 'Merged Cells Feature' demo
  Call w1.DblClickItem("|Feature Samples|V5.1 Merged Cells Feature")
  Set w2 = p.frmMergedCells
  
  ' Obtain the grid control
  Set Grid = w2.WinFormsObject("UltraGrid1")
  ' Obtain the child data view of a third row
  Set ChildView = Grid.wChildView(2)
  ' Obtain the cell value
  CellValue = ChildView.wValue(0, "Data")
End Sub

DelphiScript

procedure Main;
  var p : OleVariant;
  var w1, w2 : OleVariant;
  var Grid, CellValue, ChildView: OleVariant;
begin
  // Obtain the application process and its main form
  p := Sys.Process('SamplesExplorer');
  w1 := p.frmMain.WinFormsObject('tvwSamples');
  // Open the 'Merged Cells Feature' demo
  w1.DblClickItem('|Feature Samples|V5.1 Merged Cells Feature');
  w2 := p.frmMergedCells;
  
  // Obtain the grid control
  Grid := w2.WinFormsObject('UltraGrid1');
  // Obtain the child data view of a third row
  ChildView := Grid.wChildView[2];
  // Obtain the cell value
  CellValue := ChildView.wValue(0, 'Data');
end;

C++Script, C#Script

function Main()
{
  var p;
  var w1, w2;
  var Grid, ChildView, CellValue;

  // Obtain the application process and its main form
  p = Sys["Process"]("SamplesExplorer");
  w1 = p["frmMain"]["WinFormsObject"]("tvwSamples");
  // Open the 'Merged Cells Feature' demo
  w1["DblClickItem"]("|Feature Samples|V5.1 Merged Cells Feature");
  w2 = p["frmMergedCells"];
  
  // Obtain the grid control
  Grid = w2["WinFormsObject"]("UltraGrid1");
  // Obtain the child data view of a third row
  ChildView = Grid["wChildView"](2);
  // Obtain the cell value
  CellValue = ChildView["wValue"](0, "Data");
}

Using internal properties and objects of the grid

Each UltraGridRow object has a ChildBands collection that lists child data views related to the row. To retrieve an individual view of a collection use the Item property that returns an item with the specified zero-based index. That is, to get the desired data view you should use the following syntax:

ParentViewObj.Rows.Item(RowIndex).ChildBands.Item(ChildViewIndex)

To get the total number of child data views read the collection’s Count property.

Example

View description

JavaScript

function GetChildView (Grid, ParentView, RowIndex, ChildViewIndex)
{
  var Row;

  if (strictEqual(ParentView, null))
    ParentView = Grid;

  // Verify the row index
  if (RowIndex <= ParentView.Rows.Count)
  {
     Row = ParentView.Rows.Item(RowIndex);
     // Verify the child view index
     if (ChildViewIndex <= Row.ChildBands.Count)
       return Row.ChildBands.Item(ChildViewIndex); // Child band is found
  }
  // Child band is not found
  Log.Error ("The specified child view was not found.")
  return null;
}

JScript

function GetChildView (Grid, ParentView, RowIndex, ChildViewIndex)
{
  var Row;

  if (ParentView == null)
    ParentView = Grid;

  // Verify the row index
  if (RowIndex <= ParentView.Rows.Count)
  {
     Row = ParentView.Rows.Item(RowIndex);
     // Verify the child view index
     if (ChildViewIndex <= Row.ChildBands.Count)
       return Row.ChildBands.Item(ChildViewIndex); // Child band is found
  }
  // Child band is not found
  Log.Error ("The specified child view was not found.")
  return null;
}

Python

def GetChildView (Grid, ParentView, RowIndex, ChildViewIndex):

  if (ParentView == None):
    ParentView = Grid

  # Verify the row index
  if (RowIndex <= ParentView.Rows.Count):
     Row = ParentView.Rows.Item[RowIndex]
     # Verify the child view index
     if (ChildViewIndex <= Row.ChildBands.Count):
       return Row.ChildBands.Item[ChildViewIndex] # Child band is found
  # Child band is not found
  Log.Error ("The specified child view was not found.")
  return None

VBScript

Function GetChildView (Grid, ParentView, RowIndex, ChildViewIndex)
  Dim Row

  If ParentView Is Nothing Then
    Set ParentView = Grid
  End If

  ' Verify the row index
  If (RowIndex <= ParentView.Rows.Count) Then
    Set Row = ParentView.Rows.Item(RowIndex)
   ' Verify the child view index
    If (ChildViewIndex <= Row.ChildBands.Count) Then
      Set GetChildView = Row.ChildBands.Item(ChildViewIndex)
      Exit Function ' Child band is found
    End If
  End If

  ' Child band is not found
  Log.Error "The specified child view was not found."
  Set GetChildView = Nothing
End Function

DelphiScript

function GetChildView (Grid, ParentView, RowIndex, ChildViewIndex);
var Row: OleVariant;
begin
  if ParentView = nil then
    ParentView := Grid;

  // Verify row index
  if (RowIndex <= ParentView.Rows.Count) then
  begin
    Row := ParentView.Rows.Item[RowIndex];
    // Verify child band index
    if (ChildViewIndex <= Row.ChildBands.Count) then
    begin
      Result := Row.ChildBands.Item[ChildViewIndex]; // Child band is found
      Exit
    end
  end;

  // Child band is not found
  Log.Error ('The specified child view was not found.');
  Result := nil;
end;

C++Script, C#Script

function GetChildView (Grid, ParentView, RowIndex, ChildViewIndex)
{
  var Row;

  if (ParentView == null)
    ParentView = Grid;

  // Verify the row index
  if (RowIndex <= ParentView["Rows"]["Count"])
  {
     Row = ParentView["Rows"]["Item"](RowIndex);
     // Verify the child view index
     if (ChildViewIndex <= Row["ChildBands"]["Count"])
       return Row["ChildBands"]["Item"](ChildViewIndex); // Child band is found
  }
  // Child band is not found
  Log["Error"]("The specified child view was not found.")
  return null;
}

Accessing Rows

Retrieving a grid row depends on whether the grid represents a flat (non-hierarchical) or hierarchical dataset, or in other words whether single or multiple data views are used to display data. The information about rows is stored in the rows collection. To get the collection that corresponds to a flat dataset read the native Rows property of the entire grid object, to get a collection that corresponds to a particular data view, read the native Rows property of the view. To access the individual row in a collection use the native Rows.Item property as it returns the row specified by the zero-based index.

In order for you to be able to read native properties of a grid data view, the view must be obtained using internal properties of the grid (see above).

To obtain a row that is currently focused, you can use the grid’s ActiveRow property.

Example

View description

JavaScript

function GetRow (Grid, View, RowIndex)
{
var ActiveView;
  
  // Check whether a child view is specified
  if (strictEqual(View, null))
    ActiveView = Grid;
  else
    ActiveView = View;

  // Verify row index
  if (RowIndex > ActiveView.Rows.Count)
    return null
  else
    return ActiveView.Rows.Item(RowIndex);
}

JScript

function GetRow (Grid, View, RowIndex)
{
var ActiveView;
  
  // Check whether a child view is specified
  if (View == null)
    ActiveView = Grid;
  else
    ActiveView = View;

  // Verify row index
  if (RowIndex > ActiveView.Rows.Count)
    return null
  else
    return ActiveView.Rows.Item(RowIndex);
}

Python

def GetRow (Grid, View, RowIndex):
  
  # Check whether a child view is specified 
  if (View == None):
    ActiveView = Grid
  else:
    ActiveView = View 

  # Verify row index 
  if (RowIndex > ActiveView.Rows.Count): 
    return None
  else:
    return ActiveView.Rows.Item[RowIndex]

VBScript

Function GetRow (Grid, View, RowIndex)
Dim ActiveView
  
  ' Check whether a child view is specified
  If View Is Nothing Then
    Set ActiveView = Grid
  Else
    Set ActiveView = View
  End If

  ' Verify row index
  If (RowIndex > ActiveView.Rows.Count) Then 
    Set GetRow = Nothing
  Else
    Set GetRow = ActiveView.Rows.Item(RowIndex)
  End If
End Function

DelphiScript

function GetRow (Grid, View, RowIndex): Variant;
var ActiveView: OleVariant;
begin

  // Check whether a child view is specified
  if View = nil then
    ActiveView := Grid
  else
    ActiveView := View;
    
  // Verify row index
  if (RowIndex > ActiveView.Rows.Count) then 
    Result := nil
  else
    Result := ActiveView.Rows.Item[RowIndex]
end;

C++Script, C#Script

function GetRow (Grid, View, RowIndex)
{
var ActiveView
  
  // Check whether a child view is specified
  if (View == null)
    ActiveView = Grid;
  else
    ActiveView = View;

  // Verify row index
  if (RowIndex > ActiveView["Rows"]["Count"])
    return null
  else
    return ActiveView["Rows"]["Item"](RowIndex);
}

Accessing Columns

Accessing column objects is very similar to accessing row objects. The Columns property of a grid or view returns a collection of columns that belong to a specified view. Keep in mind that a grid has a single data view if it has a flat dataset, or has multiple data views if it represents several hierarchical datasets. To access the view corresponding to the whole grid use the native DisplayLayout.Bands.Item(0) property, while to get an UltraGridBand object corresponding to a child data view use the UltraGridRow.Band property.

In order for you to be able to read native properties of a grid data view, the view must be obtained using internal properties of the grid (see above).

A column can be specified by a column caption or by the position the column is displayed within a grid. Therefore, there are two ways to obtain a column.

To address a column by caption use the overloaded version of the Item property, named, Item_2, which returns a column that has the specified string index as a caption. The string parameter for Item_2 should match the column caption, otherwise an exception occurs. You can check the input string with the collection’s Exists method, it returns True if the collection contains an item with the given string index.

To address a column by position number you need to iterate through all the columns of a band (grid) and check the Header.VisiblePositionWithinBand property that defines the position at which the column is displayed within a band (grid).

Example

View description

JavaScript

function GetColumn (Grid, View, ColumnId)
{
  var Columns;
  
  if (strictEqual(View, null))
    Columns = Grid.DisplayLayout.Bands.Item(0).Columns
  else
    Columns = View.Band.Columns;

  if (equal(aqObject.GetVarType(ColumnId), varOleStr))
  {
    // Obtain the column by caption
    if (Columns.Exists(ColumnId))
      return Columns.Item_2(ColumnId) // Column is found
  }
  else
    // Search for the column by its visible index
    for (let i = 0; i < Columns.Count; i++)
      if (equal(Columns.Item(i).Header.VisiblePositionWithinBand, ColumnId))
        return Columns.Item(i); // Column is found

  return null; // Column is not found
}

JScript

function GetColumn (Grid, View, ColumnId)
{
  var Columns, i;
  
  if (View == null)
    Columns = Grid.DisplayLayout.Bands.Item(0).Columns
  else
    Columns = View.Band.Columns;

  if (aqObject.GetVarType(ColumnId) == varOleStr)
  {
    // Obtain the column by caption
    if (Columns.Exists(ColumnId))
      return Columns.Item_2(ColumnId) // Column is found
  }
  else
    // Search for the column by its visible index
    for (i = 0; i < Columns.Count; i++)
      if (Columns.Item(i).Header.VisiblePositionWithinBand == ColumnId)
        return Columns.Item(i); // Column is found

  return null; // Column is not found
}

Python

def GetColumn (Grid, View, ColumnId):
  
  if (View == None):
    Columns = Grid.DisplayLayout.Bands.Item[0].Columns
  else:
    Columns = View.Band.Columns

  if (aqObject.GetVarType(ColumnId) == varOleStr):
    # Obtain the column by caption
    if (Columns.Exists(ColumnId)):
      return Columns.Item_2[ColumnId] # Column is found
  else:
    # Search for the column by its visible index
    for i in range(0, Columns.Count-1):
      if (Columns.Item[i].Header.VisiblePositionWithinBand == ColumnId):
        return Columns.Item[i] # Column is found

  return None # Column is not found

VBScript

Function GetColumn (Grid, View, ColumnId)
  Dim Columns, i

  If View Is Nothing Then
    Set Columns = Grid.DisplayLayout.Bands.Item(0).Columns
  Else
    Set Columns = View.Band.Columns
  End If

  If aqObject.GetVarType(ColumnId) = varOleStr Then
    ' Obtain the column by caption
    If (Columns.Exists(ColumnId)) Then
      ' Obtain a column specified by caption
      Set GetColumn = Columns.Item_2(ColumnId) ' Column is found
      Exit Function
    End If
  Else
    ' Search for the column by its visible index
    For i = 0 to Columns.Count - 1
      If Columns.Item(i).Header.VisiblePositionWithinBand = ColumnId Then
        Set GetColumn = Columns.Item(i) ' Column is found
        Exit Function
      End If
    Next
  End If

  Set GetColumn = Nothing ' Column is not found
End Function

DelphiScript

function GetColumn (Grid, View, ColumnId): Variant;
var Columns, i : OleVariant;
begin
  if View = nil then
    Columns := Grid.DisplayLayout.Bands.Item(0).Columns
  else
    Columns := View.Band.Columns;
  
  if aqObject.GetVarType(ColumnId) = varOleStr then
  begin
    // Obtain the column by caption
    if Columns.Exists(ColumnId) then
    begin
      Result := Columns.Item_2[ColumnId]; // Column is found
      Exit
    end
  end
  else
    // Search for the column by its visible index
    for i := 0 to Columns.Count - 1 do
      if Columns.Item[i].Header.VisiblePositionWithinBand = ColumnId then
      begin
        Result := Columns.Item[i]; // Column is found
        Exit
      end;

  Result := nil; // Column is not found
end;

C++Script, C#Script

function GetColumn (Grid, View, ColumnId)
{
  var Columns, i;
  
  if (View == null)
    Columns = Grid["DisplayLayout"]["Bands"]["Item"](0)["Columns"]
  else
    Columns = View["Band"]["Columns"];

  if (aqObject["GetVarType"](ColumnId) == varOleStr)
  {
    // Obtain the column by caption
    if (Columns["Exists"](ColumnId))
      return Columns["Item_2"](ColumnId) // Column is found
  }
  else
    // Search for the column by its visible index
    for (i = 0; i < Columns["Count"]; i++)
      if (Columns["Item"](i)["Header"]["VisiblePositionWithinBand"] == ColumnId)
        return Columns["Item"](i); // Column is found

  return null; // Column is not found
}

Accessing Cells

The UltraGridCell object that represents a cell from the specified band can be obtained in a similar way. The UltraGridRow object has the Cells property that provides access to a collection of cells that belong to a given row. In turn, the cell collection object has the Item property with several overridden versions which allow for getting a cell that belongs to a specified column (Item_3) or by column name (Item_2).

In order for you to be able to read native properties of a grid data view, the view must be obtained using internal properties of the grid (see above).

To obtain a cell that is currently focused, you can use the grid’s ActiveCell property.

Example

View description

JavaScript

function GetCell (Grid, View, RowIndex, ColumnId)
{
  var Row, Column;

  // Obtain the row and column objects
  Row = GetRow (Grid, View, RowIndex);
  Column = GetColumn (Grid, View, ColumnId);

  // Obtain the cell object
  if ((strictEqual(Row, null) || strictEqual(Column, null))
    return null
  else
    return Row.Cells.Item_3(Column);
}

JScript

function GetCell (Grid, View, RowIndex, ColumnId)
{
  var Row, Column;

  // Obtain the row and column objects
  Row = GetRow (Grid, View, RowIndex);
  Column = GetColumn (Grid, View, ColumnId);

  // Obtain the cell object
  if ((Row == null) || (Column == null))
    return null
  else
    return Row.Cells.Item_3(Column);
}

Python

def GetCell (Grid, View, RowIndex, ColumnId):

  # Obtain the row and column objects
  Row = GetRow (Grid, View, RowIndex)
  Column = GetColumn (Grid, View, ColumnId)

  # Obtain the cell object
  if (Row == None) or (Column == None):
    return None
  else:
    return Row.Cells.Item_3[Column]

VBScript

Function GetCell (Grid, View, RowIndex, ColumnId)
  Dim Row, Column

  ' Obtain the row and column objects
  Set Row = GetRow (Grid, View, RowIndex)
  Set Column = GetColumn (Grid, View, ColumnId)

  ' Obtain the cell object
  If (Row Is Nothing) Or (Column Is Nothing) Then
    Set GetCell = Nothing
  Else
    Set GetCell = Row.Cells.Item_3(Column)
  End If
End Function

DelphiScript

function GetCell (Grid, View, RowIndex, ColumnId);
var Row, Column : OleVariant;
begin
  // Obtain the row and column objects
  Row := GetRow (Grid, View, RowIndex);
  Column := GetColumn (Grid, View, ColumnId);

  // Obtain the cell object
  if (Row = nil) or (Column = nil) then
    Result := nil
  else
    Result := Row.Cells.Item_3[Column];
end;

C++Script, C#Script

function GetCell (Grid, View, RowIndex, ColumnId)
{
  var Row, Column;

  // Obtain the row and column objects
  Row = GetRow (Grid, View, RowIndex);
  Column = GetColumn (Grid, View, ColumnId);

  // Obtain the cell object
  if ((Row == null) || (Column == null))
    return null
  else
    return Row["Cells"]["Item_3"](Column);
}

An Example of How to Obtain Grid Elements

The following example illustrates how to use the routines described above to get UltraGrid’s elements. It uses a “Sort” sample from the demo application “Samples Explorer” that is supplied with Infragistics UltraGrid.

JavaScript

function Main ()
{
  var p, Grid, Row, Column, ChView, Cell;

  var ColumnName = "Name";
  // Note that indexes are zero-based
  var RowIdx = 5;
  var ColIdx = 0;
  var BandIdx = 0;

  // Obtain the grid object
  p = Sys.Process("SamplesExplorer");
  Grid = p.WinFormsObject("frmSort").WinFormsObject("UltraGrid1");

  Row = GetRow (Grid, null, RowIdx);
  if (!strictEqual(Row, null))
    Log.Message ("Row with index " + aqConvert.VarToStr(Row.Index) + " is found.");

  Column = GetColumn (Grid, null, ColIdx);
  if (!strictEqual(Column, null))
    Log.Message ("Column '" + aqConvert.VarToStr(Column.Key) + "' is found.");

  ChView = GetChildView (Grid, null, RowIdx, BandIdx);
  if (!strictEqual(ChView, null))
    Log.Message ("Band '" + aqConvert.VarToStr(ChView.Key) + "' is found.");

  Cell = GetCell (Grid, null, RowIdx, ColumnName);
  if (!strictEqual(Cell, null))
    Log.Message ("Cell found. Cell Value: " + aqConvert.VarToStr(Cell.Value));
}

JScript

function Main ()
{
  var p, Grid, Row, Column, ChView, Cell;

  var ColumnName = "Name";
  // Note that indexes are zero-based
  var RowIdx = 5;
  var ColIdx = 0;
  var BandIdx = 0;

  // Obtain the grid object
  p = Sys.Process("SamplesExplorer");
  Grid = p.WinFormsObject("frmSort").WinFormsObject("UltraGrid1");

  Row = GetRow (Grid, null, RowIdx);
  if (Row != null)
    Log.Message ("Row with index " + aqConvert.VarToStr(Row.Index) + " is found.");

  Column = GetColumn (Grid, null, ColIdx);
  if (Column != null)
    Log.Message ("Column '" + aqConvert.VarToStr(Column.Key) + "' is found.");

  ChView = GetChildView (Grid, null, RowIdx, BandIdx);
  if (ChView != null)
    Log.Message ("Band '" + aqConvert.VarToStr(ChView.Key) + "' is found.");

  Cell = GetCell (Grid, null, RowIdx, ColumnName);
  if (Cell != null)
    Log.Message ("Cell found. Cell Value: " + aqConvert.VarToStr(Cell.Value));
}

Python

def Main ():

  ColumnName = "Name"
  # Note that indexes are zero-based
  RowIdx = 5
  ColIdx = 0
  BandIdx = 0

  # Obtain the grid object
  p = Sys.Process("SamplesExplorer")
  Grid = p.WinFormsObject("frmSort").WinFormsObject("UltraGrid1")

  Row = GetRow (Grid, None, RowIdx)
  if (Row != None):
    Log.Message ("Row with index " + aqConvert.VarToStr(Row.Index) + " is found.")

  Column = GetColumn (Grid, None, ColIdx)
  if (Column != None):
    Log.Message ("Column '" + aqConvert.VarToStr(Column.Key) + "' is found.")

  ChView = GetChildView (Grid, None, RowIdx, BandIdx)
  if (ChView != None):
    Log.Message ("Band '" + aqConvert.VarToStr(ChView.Key) + "' is found.")

  Cell = GetCell (Grid, None, RowIdx, ColumnName)
  if (Cell != None):
    Log.Message ("Cell found. Cell Value: " + aqConvert.VarToStr(Cell.Value))

VBScript

Sub Main
  Dim p, Grid, Row, Column, ChView, Cell, ColumnName, RowIdx, ColIdx, BandIdx

  ColumnName = "Name"
  ' Note that indexes are zero-based
  RowIdx = 5
  ColIdx = 0
  BandIdx = 0

  ' Obtain the grid object
  Set p = Sys.Process("SamplesExplorer")
  Set Grid = p.WinFormsObject("frmSort").WinFormsObject("UltraGrid1")

  Set Row = GetRow(Grid, Nothing, RowIdx)
  If Not Row Is Nothing Then
    Log.Message ("Row with index " & aqConvert.VarToStr(Row.Index) & " is found.")
  End If

  Set Column = GetColumn(Grid, Nothing, ColIdx)
  If Not Column Is Nothing Then
    Log.Message ("Column '" & aqConvert.VarToStr(Column.Key) & "' is found.")
  End If

  Set ChView = GetChildView(Grid, Nothing, RowIdx, BandIdx)
  If Not ChView Is Nothing Then
    Log.Message ("Band '" & aqConvert.VarToStr(ChView.Key) & "' is found.")
  End If

  Set Cell = GetCell(Grid, Nothing, RowIdx, ColumnName)
  If Not Cell Is Nothing Then
    Log.Message ("Cell found. Cell Value: " & aqConvert.VarToStr(Cell.Value))
  End If
End Sub

DelphiScript

procedure Main;
var
  p, Grid, Row, Column, ChView, Cell,
  RowIdx, ColIdx, BandIdx, ColumnName : OleVariant;
begin
  ColumnName := 'Name';
  // Note that indexes are zero-based
  RowIdx := 5;
  ColIdx := 0;
  BandIdx := 0;

  // Obtain the grid object
  p := Sys.Process('SamplesExplorer');
  Grid := p.WinFormsObject('frmSort').WinFormsObject('UltraGrid1');

  Row := GetRow (Grid, nil, RowIdx);
  if Row <> nil then
    Log.Message ('Row with index ' + aqConvert.VarToStr(Row.Index) + ' is found.');
 
  Column := GetColumn (Grid, nil, ColIdx);
  if Column <> nil then
    Log.Message ('Column "' + aqConvert.VarToStr(Column.Key) + '" is found.');

  ChView := GetChildView (Grid, nil, RowIdx, BandIdx);
  if ChView <> nil then
    Log.Message ('Band "' + aqConvert.VarToStr(ChView.Key) + '" is found.');

  Cell := GetCell (Grid, nil, RowIdx, ColumnName);
  if Cell <> nil then
    Log.Message ('Cell found. Cell Value: ' + aqConvert.VarToStr(Cell.Value));
end;

C++Script, C#Script

function Main()
{
  var p, Grid, Row, Column, ChView, Cell;

  var ColumnName = "Name";
  // Note that indexes are zero-based
  var RowIdx = 5;
  var ColIdx = 0;
  var BandIdx = 0;

  // Obtain the grid object
  p = Sys["Process"]("SamplesExplorer");
  Grid = p["WinFormsObject"]("frmSort")["WinFormsObject"]("UltraGrid1");

  Row = GetRow (Grid, null, RowIdx);
  if (Row != null)
    Log["Message"]("Row with index " + aqConvert["VarToStr"](Row["Index"]) + " is found.");

  Column = GetColumn (Grid, null, ColIdx);
  if (Column != null)
    Log["Message"]("Column '" + aqConvert["VarToStr"](Column["Key"]) + "' is found.");

  ChView = GetChildView (Grid, null, RowIdx, BandIdx);
  if (ChView != null)
    Log["Message"]("Band '" + aqConvert["VarToStr"](ChView["Key"]) + "' is found.");

  Cell = GetCell (Grid, null, RowIdx, ColumnName);
  if (Cell != null)
    Log["Message"]("Cell found. Cell Value: " + aqConvert["VarToStr"](Cell["Value"]));
}

See Also

Working With Infragistics UltraGrid
Obtaining and Setting Cell Values in Infragistics UltraGrid
Selecting Cells in Infragistics UltraGrid
Iterating Through Rows in Infragistics UltraGrid
Searching for Records in Infragistics UltraGrid
Infragistics UltraGrid Support
InfragisticsUltraGridView Object

Highlight search results