Working With Specific In-place Editors in Developer Express XtraGrid

Applies to TestComplete 15.47, last modified on January 20, 2023

The XtraGrid control offers a variety of in-place editors that can be used in the XtraGrid control: combo boxes, check boxes, radio buttons, spin boxes and various drop-down editors. In Obtaining and Setting Cell Values in Developer Express XtraGrid, we defined the SetCellValue and InputCellValue routines that can be used to change grid cell values in general. However, you may need to modify the cell value in a specific way for the cell editor, for example, increase the value using the spin buttons, or simulate actions in the cell’s dropdown editor. This topic describes how you can access in-place editors in scripts and work with certain types of in-place editors.

To perform these actions, TestComplete should have access to internal objects, properties and methods of the XtraGrid control. For this purpose, the .NET Application Support and Developer Express Control Support plugins must be installed and enabled. The latter lets you work with the XtraGrid control using methods and properties of the DevExpressXtraGrid object. Without this plugin, you will not be able to work with XtraGrid controls using their internal methods and properties.

When testing Developer Express XtraGrid controls, use specific methods and properties of the corresponding DevExpressXtraGrid 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 an XtraGrid 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.

Accessing In-place Editors

When you start editing the grid cell value, that is, after you select the cell and activate the edit mode, the grid creates the corresponding edit control (in-place editor) for this. To access the current editor, use the grid’s internal FocusedView.ActiveEditor property. After the user has finished editing the cell value, the editor object is destroyed. After that, the FocusedView.ActiveEditor property returns the empty value. Thus, the editor object only exists and can be accessed when it is active. To check if the grid control is in the editing mode, you can use the grid’s FocusedView.IsEditing

After you obtain the object corresponding to the edit control, you can use its internal properties and methods to perform the desired actions. For example, you can use the Text property to get or set the editor’s current text, and the ShowPopup method to display the drop-down window. Note that after you have modified the cell value, you should close the editor to save the changes made.

In the following sections, you will find information on performing typical operations over some in-place editors.

Working With ComboBox Editors

The XtraGrid Suite provides several types of combo box editors: usual combo boxes, image combo boxes and a text editor with the list of the recently used items. It is possible to select items in the combo box editor using the editor’s internal properties: the SelectedItem property lets you get or set the selected item itself, and the SelectedIndex property specifies the selected item’s index.

Note that if the editor’s Properties_2.AutoComplete property is True, the combo box editor supports the automatic completion feature, which means that you can select a combo box item by typing the item caption into the editor.

Example

The SetCellSelectedItem routine in the following code snippet demonstrates how you can select items in the combo box editors. It lets you select items specified by their caption or index. If the editor’s autocomplete feature is enabled, the item is selected by “typing” its caption into the editor rather that using the SelectedItem property. For the SetCellSelectedItem usage examples, see the Example section at the end of this topic.

View example description

JavaScript

function SetCellSelectedItem (Grid, ViewObj, RowIndex, ColumnId, Item)
{
  // Select the cell
  if (strictEqual(ViewObj, null))
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  var Editor = Grid.FocusedView.ActiveEditor;
  if (equal(Editor.ClrClassName, "ComboBoxEdit") || equal(Editor.ClrClassName, "ImageComboBoxEdit") || equal(Editor.ClrClassName, "MRUEdit"))
  {
    // Select the specified item
    if (equal(aqObject.GetVarType (Item), varOleStr))
    {
      if (Editor.Properties_2.AutoComplete)
        Grid.Keys (Item);
      else
        Editor.SelectedItem = Item;
    }
    else
      Editor.SelectedIndex = Item;

    // Save the changes
    CloseCellEditor (Grid);
  }
  else
    Log.Error ("Cannot find the in-place ComboBox editor.");
}

JScript

function SetCellSelectedItem (Grid, ViewObj, RowIndex, ColumnId, Item)
{
  // Select the cell
  if (ViewObj == null)
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  var Editor = Grid.FocusedView.ActiveEditor;
  if ((Editor.ClrClassName == "ComboBoxEdit") || (Editor.ClrClassName == "ImageComboBoxEdit") || (Editor.ClrClassName == "MRUEdit"))
  {
    // Select the specified item
    if (aqObject.GetVarType (Item) == varOleStr)
    {
      if (Editor.Properties_2.AutoComplete)
        Grid.Keys (Item);
      else
        Editor.SelectedItem = Item;
    }
    else
      Editor.SelectedIndex = Item;

    // Save the changes
    CloseCellEditor (Grid);
  }
  else
    Log.Error ("Cannot find the in-place ComboBox editor.");
}

Python

def SetCellSelectedItem (Grid, ViewObj, RowIndex, ColumnId, Item):
  # Select the cell
  if (ViewObj == None):
    Grid.ClickCell (RowIndex, ColumnId)
  else:
    ViewObj.ClickCell (RowIndex, ColumnId)
  # Activate the in-place editor
  ActivateCellEditor (Grid)

  # Get the editor object
  Editor = Grid.FocusedView.ActiveEditor
  if ((Editor.ClrClassName == "ComboBoxEdit") or (Editor.ClrClassName == "ImageComboBoxEdit") or (Editor.ClrClassName == "MRUEdit")):
    # Select the specified item
    if (aqObject.GetVarType (Item) == varOleStr):
      if (Editor.Properties_2.AutoComplete):
        Grid.Keys (Item)
      else:
        Editor.SelectedItem = Item
    else:
      Editor.SelectedIndex = Item

    # Save the changes
    CloseCellEditor (Grid)
  else:
    Log.Error ("Cannot find the in-place ComboBox editor.")

VBScript

Sub SetCellSelectedItem (Grid, ViewObj, RowIndex, ColumnId, Item)
  Dim Editor

  ' Select the cell
  If ViewObj Is Nothing Then
    Call Grid.ClickCell (RowIndex, ColumnId)
  Else
    Call ViewObj.ClickCell (RowIndex, ColumnId)
  End If
  ' Activate the in-place editor
  ActivateCellEditor (Grid)

  ' Get the editor object
  Set Editor = Grid.FocusedView.ActiveEditor
  If (Editor.ClrClassName = "ComboBoxEdit") Or (Editor.ClrClassName = "ImageComboBoxEdit") _
      Or (Editor.ClrClassName = "MRUEdit") Then
    ' Select the specified item
    If aqObject.GetVarType (Item) = varOleStr Then
      If Editor.Properties_2.AutoComplete Then
        Grid.Keys (Item)
      Else
        Editor.SelectedItem = Item
      End If
    Else
      Editor.SelectedIndex = Item
    End If

    ' Save the changes
    CloseCellEditor (Grid)
  Else
    Log.Error ("Cannot find the in-place ComboBox editor.")
  End If
End Sub

DelphiScript

procedure SetCellSelectedItem (Grid, ViewObj, RowIndex, ColumnId, Item);
var Editor : OleVariant;
begin
  // Select the cell
  if ViewObj = nil then
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor := Grid.FocusedView.ActiveEditor;
  if (Editor.ClrClassName = 'ComboBoxEdit') or (Editor.ClrClassName = 'ImageComboBoxEdit') or (Editor.ClrClassName = 'MRUEdit') then
  begin
    // Select the specified item
    if aqObject.GetVarType (Item) = varOleStr then
    begin
      if Editor.Properties_2.AutoComplete then
        Grid.Keys (Item)
      else
        Editor.SelectedItem := Item;
    end
    else
      Editor.SelectedIndex := Item;

    // Save the changes
    CloseCellEditor (Grid);
  end
  else
    Log.Error ('Cannot find the in-place ComboBox editor.');
end;

C++Script, C#Script

function SetCellSelectedItem (Grid, ViewObj, RowIndex, ColumnId, Item)
{
  // Select the cell
  if (ViewObj == null)
    Grid["ClickCell"](RowIndex, ColumnId)
  else
    ViewObj["ClickCell"](RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  var Editor = Grid["FocusedView"]["ActiveEditor"];
  if ((Editor["ClrClassName"] == "ComboBoxEdit") || (Editor["ClrClassName"] == "ImageComboBoxEdit") || (Editor["ClrClassName"] == "MRUEdit"))
  {
    // Select the specified item
    if (aqObject["GetVarType"](Item) == varOleStr)
    {
      if (Editor["Properties_2"]["AutoComplete"])
        Grid["Keys"](Item);
      else
        Editor["SelectedItem"] = Item;
    }
    else
      Editor["SelectedIndex"] = Item;

    // Save the changes
    CloseCellEditor (Grid);
  }
  else
    Log["Error"]("Cannot find the in-place ComboBox editor.");
}

Working With CheckBox Editors

You can change the checked state of a cell that uses the CheckBox editor in the following ways:

  • By clicking anywhere within the cell. For this purpose, you can use the ClickCell action of a DevExpressXtraGrid or DevExpressXtraGridView object.
  • By selecting the cell, activating its in-place editor and pressing the Space key.
  • By selecting the cell, activating its in-place editor and using the Checked or CheckState property of the editor object. The Checked property lets you get or set whether the cell is checked (True) or unchecked (False). The CheckState property can be used for the check editors that can have three states - checked, unchecked and indeterminate.
Example

The following SetCellChecked routine demonstrates how you can modify a cell’s check state. You can find the example of using this routine in the Example section below.

View example description

JavaScript

function SetCellChecked (Grid, ViewObj, RowIndex, ColumnId, Checked)
{
  // Select the cell
  if (strictEqual(ViewObj, null))
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  let Editor = Grid.FocusedView.ActiveEditor;
  if (equal(Editor.ClrClassName, "CheckEdit"))
  {
    // Change the checked state
    Editor.Checked = Checked;
    CloseCellEditor (Grid);
  }
  else
    Log.Error ("Cannot find the in-place CheckBox editor.");
}

JScript

function SetCellChecked (Grid, ViewObj, RowIndex, ColumnId, Checked)
{
  // Select the cell
  if (ViewObj == null)
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  var Editor = Grid.FocusedView.ActiveEditor;
  if (Editor.ClrClassName == "CheckEdit")
  {
    // Change the checked state
    Editor.Checked = Checked;
    CloseCellEditor (Grid);
  }
  else
    Log.Error ("Cannot find the in-place CheckBox editor.");
}

Python

def SetCellChecked (Grid, ViewObj, RowIndex, ColumnId, Checked):
  # Select the cell
  if (ViewObj == None):
    Grid.ClickCell (RowIndex, ColumnId)
  else:
    ViewObj.ClickCell (RowIndex, ColumnId)
  # Activate the in-place editor
  ActivateCellEditor (Grid)

  # Get the editor object
  Editor = Grid.FocusedView.ActiveEditor
  if (Editor.ClrClassName == "CheckEdit"):
    # Change the checked state
    Editor.Checked = Checked
    CloseCellEditor (Grid)
  else:
    Log.Error ("Cannot find the in-place CheckBox editor.")

VBScript

Sub SetCellChecked (Grid, ViewObj, RowIndex, ColumnId, Checked)
  Dim Editor

  ' Select the cell
  If ViewObj Is Nothing Then
    Call Grid.ClickCell (RowIndex, ColumnId)
  Else
    Call ViewObj.ClickCell (RowIndex, ColumnId)
  End If
  ' Activate the in-place editor
  ActivateCellEditor (Grid)

  ' Get the editor object
  Set Editor = Grid.FocusedView.ActiveEditor
  If Editor.ClrClassName = "CheckEdit" Then
    ' Change the checked state
    Editor.Checked = Checked
    CloseCellEditor (Grid)
  Else
    Log.Error ("Cannot find the in-place CheckBox editor.")
  End If
End Sub

DelphiScript

procedure SetCellChecked (Grid, ViewObj, RowIndex, ColumnId, Checked);
var Editor : OleVariant;
begin
  // Select the cell
  if ViewObj = nil then
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor := Grid.FocusedView.ActiveEditor;
  if Editor.ClrClassName = 'CheckEdit' then
  begin
    // Change the checked state
    Editor.Checked := Checked;
    CloseCellEditor (Grid);
  end
  else
    Log.Error ('Cannot find the in-place CheckBox editor.')
end;

C++Script, C#Script

function SetCellChecked (Grid, ViewObj, RowIndex, ColumnId, Checked)
{
  // Select the cell
  if (ViewObj == null)
    Grid["ClickCell"](RowIndex, ColumnId)
  else
    ViewObj["ClickCell"](RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  var Editor = Grid["FocusedView"]["ActiveEditor"];
  if (Editor["ClrClassName"] == "CheckEdit")
  {
    // Change the checked state
    Editor["Checked"] = Checked;
    CloseCellEditor (Grid);
  }
  else
    Log["Error"]("Cannot find the in-place CheckBox editor.");
}

Working With RadioGroup Editors

You can change the selected radio button in the RadioGroup editor using its SelectedIndex property. This property lets you get or set the currently selected radio button by its index within the group, that is, within the editor’s Properties_2.Items collection.

Example

The code snippet below contains the SetCellRadioButton routine that can be used to change the selected radio button in the cell. It lets you select the radio button by its index or by its caption. In the latter case, the routine searches for the desired button by iterating through the editor’s Properties_2.items collection and comparing each button’s Description property with the specified value.

View example description

JavaScript

function SetCellRadioButton (Grid, ViewObj, RowIndex, ColumnId, ButtonId)
{
  var Editor, Buttons, i;

  // Select the cell
  if (strictEqual(ViewObj, null))
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor = Grid.FocusedView.ActiveEditor;
  if (equal(Editor.ClrClassName, "RadioGroup"))
  {
    if (equal(aqObject.GetVarType(ButtonId), varOleStr))
    {
      // The radio button is specified by its caption
      Buttons = Editor.Properties_2.Items;
      for (i=0; i<Buttons.Count; i++)
        if (equal(Buttons.Item(i).Description.OleValue, ButtonId))
        {
          Editor.SelectedIndex = i;
          break;
        }
    }
    else
      // The radio button is specified by its index
      Editor.SelectedIndex = ButtonId;

    // Apply the changes
    CloseCellEditor (Grid);
  }
  else
    Log.Error ("Cannot find the in-place RadioGroup editor.");
}

JScript

function SetCellRadioButton (Grid, ViewObj, RowIndex, ColumnId, ButtonId)
{
  var Editor, Buttons, i;

  // Select the cell
  if (ViewObj == null)
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor = Grid.FocusedView.ActiveEditor;
  if (Editor.ClrClassName == "RadioGroup")
  {
    if (aqObject.GetVarType(ButtonId) == varOleStr)
    {
      // The radio button is specified by its caption
      Buttons = Editor.Properties_2.Items;
      for (i=0; i<Buttons.Count; i++)
        if (Buttons.Item(i).Description.OleValue == ButtonId)
        {
          Editor.SelectedIndex = i;
          break;
        }
    }
    else
      // The radio button is specified by its index
      Editor.SelectedIndex = ButtonId;

    // Apply the changes
    CloseCellEditor (Grid);
  }
  else
    Log.Error ("Cannot find the in-place RadioGroup editor.");
}

Python

def SetCellRadioButton (Grid, ViewObj, RowIndex, ColumnId, ButtonId):

  # Select the cell
  if (ViewObj == None):
    Grid.ClickCell (RowIndex, ColumnId)
  else:
    ViewObj.ClickCell (RowIndex, ColumnId)
  # Activate the in-place editor
  ActivateCellEditor (Grid)

  # Get the editor object
  Editor = Grid.FocusedView.ActiveEditor
  if (Editor.ClrClassName == "RadioGroup"):
    if (aqObject.GetVarType(ButtonId) == varOleStr):
      # The radio button is specified by its caption
      Buttons = Editor.Properties_2.Items
      for i in range(0, Buttons.Count-1):
        if (Buttons.Item[i].Description.OleValue == ButtonId):
          Editor.SelectedIndex = i
          break
    else:
      # The radio button is specified by its index
      Editor.SelectedIndex = ButtonId

    # Apply the changes
    CloseCellEditor (Grid)
  else:
    Log.Error ("Cannot find the in-place RadioGroup editor.")

VBScript

Sub SetCellRadioButton (Grid, ViewObj, RowIndex, ColumnId, ButtonId)
  Dim Editor, Buttons, i

  ' Select the cell
  If ViewObj Is Nothing Then
    Call Grid.ClickCell (RowIndex, ColumnId)
  Else
    Call ViewObj.ClickCell (RowIndex, ColumnId)
  End If
  ' Activate the in-place editor
  ActivateCellEditor (Grid)

  ' Get the editor object
  Set Editor = Grid.FocusedView.ActiveEditor
  If Editor.ClrClassName = "RadioGroup" Then
    If aqObject.GetVarType(ButtonId) = varOleStr Then
      ' The radio button is specified by its caption
      Set Buttons = Editor.Properties_2.Items
      For i=0 To Buttons.Count-1
        If Buttons.Item(i).Description.OleValue = ButtonId Then
          Editor.SelectedIndex = i
          Exit For
        End If
      Next
    Else
      ' The radio button is specified by its index
      Editor.SelectedIndex = ButtonId
    End If

    ' Apply the changes
    CloseCellEditor (Grid)
  Else
    Log.Error ("Cannot find the in-place RadioGroup editor.")
  End If
End Sub

DelphiScript

procedure SetCellRadioButton (Grid, ViewObj, RowIndex, ColumnId, ButtonId);
var Editor, Buttons, i : OleVariant;
begin
  // Select the cell
  if ViewObj = nil then
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor := Grid.FocusedView.ActiveEditor;
  if Editor.ClrClassName = 'RadioGroup' then
  begin
    if aqObject.GetVarType(ButtonId) = varOleStr then
    begin
      // The radio button is specified by its caption
      Buttons := Editor.Properties_2.Items;
      for i:=0 to Buttons.Count-1 do
        if Buttons.Item[i].Description.OleValue = ButtonId then
        begin
          Editor.SelectedIndex := i;
          Break
        end
    end
    else
      // The radio button is specified by its index
      Editor.SelectedIndex := ButtonId;

    // Apply the changes
    CloseCellEditor (Grid);
  end
  else
    Log.Error ('Cannot find the in-place RadioGroup editor.');
end;

C++Script, C#Script

function SetCellRadioButton (Grid, ViewObj, RowIndex, ColumnId, ButtonId)
{
  var Editor, Buttons, i;

  // Select the cell
  if (ViewObj == null)
    Grid["ClickCell"](RowIndex, ColumnId)
  else
    ViewObj["ClickCell"](RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor = Grid["FocusedView"]["ActiveEditor"];
  if (Editor["ClrClassName"] == "RadioGroup")
  {
    if (aqObject["GetVarType"](ButtonId) == varOleStr)
    {
      // The radio button is specified by its caption
      Buttons = Editor["Properties_2"]["Items"];
      for (i=0; i<Buttons["Count"]; i++)
        if (Buttons["Item"](i)["Description"]["OleValue"] == ButtonId)
        {
          Editor["SelectedIndex"] = i;
          break;
        }
    }
    else
      // The radio button is specified by its index
      Editor["SelectedIndex"] = ButtonId;

    // Apply the changes
    CloseCellEditor (Grid);
  }
  else
    Log["Error"]("Cannot find the in-place RadioGroup editor.");
}

Working With SpinBox Editors

The spin editor’s value can de adjusted using the editor’s spin buttons. You can “press” these buttons by simulating the corresponding keyboard shortcuts with the Keys actions. Which shortcuts that can be used to increase or decrease the value depends on the editor’s Properties_2.UseCtrlIncrement property. If this property is True, the Ctrl+Up Arrow and Ctrl+Down Arrow shortcuts are used, otherwise the Up Arrow and Down Arrow are used.

Example

The following code snippet contains the DoCellSpinUp and DoCellSpinDown routines that can be used to increase or decrease the spin editor value. You can find the usage example of these routines in the Example section.

View example description

JavaScript

function DoCellSpinUp (Grid, ViewObj, RowIndex, ColumnId, Times)
{
  var Editor, shortcut;

  // Select the cell
  if (strictEqual(ViewObj, null))
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor = Grid.FocusedView.ActiveEditor;
  if (equal(Editor.ClrClassName, "SpinEdit"))
  {
    // Determine which shortcut is used to increment the value
    if (Editor.Properties_2.UseCtrlIncrement)
      shortcut = "^[Up]"
    else
      shortcut = "[Up]";

    // Simulate the shortcut
    for (let i=0; i<Times; i++)
      Grid.Keys (shortcut);

    // Apply the changes
    CloseCellEditor (Grid);
  }
  else
    Log.Error ("Cannot find the in-place SpinBox editor.");
}

function DoCellSpinDown (Grid, ViewObj, RowIndex, ColumnId, Times)
{
  var Editor, shortcut;

  // Select the cell
  if (strictEqual(ViewObj, null))
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor = Grid.FocusedView.ActiveEditor;
  if (equal(Editor.ClrClassName, "SpinEdit"))
  {
    // Determine which shortcut is used to decrement the value
    if (Editor.Properties_2.UseCtrlIncrement)
      shortcut = "^[Down]"
    else
      shortcut = "[Down]";

    // Simulate the shortcut
    for (let i=0; i<Times; i++)
      Grid.Keys (shortcut);

    // Apply the changes
    CloseCellEditor (Grid);
  }
  else
    Log.Error ("Cannot find the in-place SpinBox editor.");
}

JScript

function DoCellSpinUp (Grid, ViewObj, RowIndex, ColumnId, Times)
{
  var Editor, shortcut, i;

  // Select the cell
  if (ViewObj == null)
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor = Grid.FocusedView.ActiveEditor;
  if (Editor.ClrClassName == "SpinEdit")
  {
    // Determine which shortcut is used to increment the value
    if (Editor.Properties_2.UseCtrlIncrement)
      shortcut = "^[Up]"
    else
      shortcut = "[Up]";

    // Simulate the shortcut
    for (i=0; i<Times; i++)
      Grid.Keys (shortcut);

    // Apply the changes
    CloseCellEditor (Grid);
  }
  else
    Log.Error ("Cannot find the in-place SpinBox editor.");
}

function DoCellSpinDown (Grid, ViewObj, RowIndex, ColumnId, Times)
{
  var Editor, shortcut, i;

  // Select the cell
  if (ViewObj == null)
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor = Grid.FocusedView.ActiveEditor;
  if (Editor.ClrClassName == "SpinEdit")
  {
    // Determine which shortcut is used to decrement the value
    if (Editor.Properties_2.UseCtrlIncrement)
      shortcut = "^[Down]"
    else
      shortcut = "[Down]";

    // Simulate the shortcut
    for (i=0; i<Times; i++)
      Grid.Keys (shortcut);

    // Apply the changes
    CloseCellEditor (Grid);
  }
  else
    Log.Error ("Cannot find the in-place SpinBox editor.");
}

Python

def DoCellSpinUp (Grid, ViewObj, RowIndex, ColumnId, Times):

  # Select the cell
  if (ViewObj == None):
    Grid.ClickCell (RowIndex, ColumnId)
  else:
    ViewObj.ClickCell (RowIndex, ColumnId)
  # Activate the in-place editor
  ActivateCellEditor (Grid)

  # Get the editor object
  Editor = Grid.FocusedView.ActiveEditor
  if (Editor.ClrClassName == "SpinEdit"):
    # Determine which shortcut is used to increment the value
    if (Editor.Properties_2.UseCtrlIncrement):
      shortcut = "^[Up]"
    else:
      shortcut = "[Up]"

    # Simulate the shortcut
    for i in range (0, Times-1):
      Grid.Keys (shortcut)

    # Apply the changes
    CloseCellEditor (Grid)
  else:
    Log.Error ("Cannot find the in-place SpinBox editor.")

def DoCellSpinDown (Grid, ViewObj, RowIndex, ColumnId, Times):

  # Select the cell
  if (ViewObj == None):
    Grid.ClickCell (RowIndex, ColumnId)
  else:
    ViewObj.ClickCell (RowIndex, ColumnId)
  # Activate the in-place editor
  ActivateCellEditor (Grid)

  # Get the editor object
  Editor = Grid.FocusedView.ActiveEditor
  if (Editor.ClrClassName == "SpinEdit"):
    # Determine which shortcut is used to decrement the value
    if (Editor.Properties_2.UseCtrlIncrement):
      shortcut = "^[Down]"
    else:
      shortcut = "[Down]"

    # Simulate the shortcut
    for i in range(0, Times-1):
      Grid.Keys (shortcut)

    # Apply the changes
    CloseCellEditor (Grid)
  else:
    Log.Error ("Cannot find the in-place SpinBox editor.")

VBScript

Sub DoCellSpinUp (Grid, ViewObj, RowIndex, ColumnId, Times)
  Dim Editor, shortcut, i

  ' Select the cell
  If ViewObj Is Nothing Then
    Call Grid.ClickCell (RowIndex, ColumnId)
  Else
    Call ViewObj.ClickCell (RowIndex, ColumnId)
  End If
  ' Activate the in-place editor
  ActivateCellEditor (Grid)

  ' Get the editor object
  Set Editor = Grid.FocusedView.ActiveEditor
  If Editor.ClrClassName = "SpinEdit" Then
    ' Determine which shortcut is used to increment the value
    If Editor.Properties_2.UseCtrlIncrement Then
      shortcut = "^[Up]"
    Else
      shortcut = "[Up]"
    End If

    ' Simulate the shortcut
    For i=0 To Times-1
      Call Grid.Keys (shortcut)
    Next

    ' Apply the changes
    CloseCellEditor (Grid)
  Else
    Log.Error ("Cannot find the in-place SpinBox editor.")
  End If
End Sub

Sub DoCellSpinDown (Grid, ViewObj, RowIndex, ColumnId, Times)
  Dim Editor, shortcut, i

  ' Select the cell
  If ViewObj Is Nothing Then
    Call Grid.ClickCell (RowIndex, ColumnId)
  Else
    Call ViewObj.ClickCell (RowIndex, ColumnId)
  End If
  ' Activate the in-place editor
  ActivateCellEditor (Grid)

  ' Get the editor object
  Set Editor = Grid.FocusedView.ActiveEditor
  If Editor.ClrClassName = "SpinEdit" Then
    ' Determine which shortcut is used to decrement the value
    If Editor.Properties_2.UseCtrlIncrement Then
      shortcut = "^[Down]"
    Else
      shortcut = "[Down]"
    End If

    ' Simulate the shortcut
    For i=0 To Times-1
      Call Grid.Keys (shortcut)
    Next

    ' Apply the changes
    CloseCellEditor (Grid)
  Else
    Log.Error ("Cannot find the in-place SpinBox editor.")
  End If
End Sub

DelphiScript

procedure DoCellSpinUp (Grid, ViewObj, RowIndex, ColumnId, Times);
var Editor, shortcut, i : OleVariant;
begin
  // Select the cell
  if ViewObj = nil then
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor := Grid.FocusedView.ActiveEditor;
  if Editor.ClrClassName = 'SpinEdit' then
  begin
    // Determine which shortcut is used to increment the value
    if Editor.Properties_2.UseCtrlIncrement then
      shortcut := '^[Up]'
    else
      shortcut := '[Up]';

    // Simulate the shortcut
    for i:=0 to Times-1 do
      Grid.Keys (shortcut);

    // Apply the changes
    CloseCellEditor (Grid);
  end
  else
    Log.Error ('Cannot find the in-place SpinBox editor.');
end;

procedure DoCellSpinDown (Grid, ViewObj, RowIndex, ColumnId, Times);
var Editor, shortcut, i : OleVariant;
begin
  // Select the cell
  if ViewObj = nil then
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor := Grid.FocusedView.ActiveEditor;
  if Editor.ClrClassName = 'SpinEdit' then
  begin
    // Determine which shortcut is used to decrement the value
    if Editor.Properties_2.UseCtrlIncrement then
      shortcut := '^[Down]'
    else
      shortcut := '[Down]';

    // Simulate the shortcut
    for i:=0 to Times-1 do
      Grid.Keys (shortcut);

    // Apply the changes
    CloseCellEditor (Grid);
  end
  else
    Log.Error ('Cannot find the in-place SpinBox editor.');
end;

C++Script, C#Script

function DoCellSpinUp (Grid, ViewObj, RowIndex, ColumnId, Times)
{
  var Editor, shortcut, i;

  // Select the cell
  if (ViewObj == null)
    Grid["ClickCell"](RowIndex, ColumnId)
  else
    ViewObj["ClickCell"](RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor = Grid["FocusedView"]["ActiveEditor"];
  if (Editor["ClrClassName"] == "SpinEdit")
  {
    // Determine which shortcut is used to increment the value
    if (Editor["Properties_2"]["UseCtrlIncrement"])
      shortcut = "^[Up]"
    else
      shortcut = "[Up]";

    // Simulate the shortcut
    for (i=0; i<Times; i++)
      Grid["Keys"](shortcut);

    // Apply the changes
    CloseCellEditor (Grid);
  }
  else
    Log["Error"]("Cannot find the in-place SpinBox editor.");
}

function DoCellSpinDown (Grid, ViewObj, RowIndex, ColumnId, Times)
{
  var Editor, shortcut, i;

  // Select the cell
  if (ViewObj == null)
    Grid["ClickCell"](RowIndex, ColumnId)
  else
    ViewObj["ClickCell"](RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor = Grid["FocusedView"]["ActiveEditor"];
  if (Editor["ClrClassName"] == "SpinEdit")
  {
    // Determine which shortcut is used to decrement the value
    if (Editor["Properties_2"]["UseCtrlIncrement"])
      shortcut = "^[Down]"
    else
      shortcut = "[Down]";

    // Simulate the shortcut
    for (i=0; i<Times; i++)
      Grid["Keys"](shortcut);

    // Apply the changes
    CloseCellEditor (Grid);
  }
  else
    Log["Error"]("Cannot find the in-place SpinBox editor.");
}

Clicking Editor Buttons

The in-place editors used by the XtraGrid control may have embedded buttons that may modify the cell value in a special way, invoke custom dialogs, and so on. In many cases, the embedded buttons can be pressed using the corresponding shortcuts. For example, the common shortcut for the combo button is F4, and the spin buttons can be “pressed” using Up Arrow and Down Arrow keys. However, not all of the editor’s buttons may have the shortcut assigned. In this case, you can simulate a mouse click on the buttons with the Click action.

To determine the button coordinates, use the following statement:

editorObj.ViewInfo.ButtonInfoById(Index).Bounds

Here, editorObj is the object corresponding to the in-place editor, and Index parameter specifies the zero-based index of the button within the editor.

Example

The following example illustrates how you can click the in-place editor’s embedded buttons.

View example description

JavaScript

function TestClickInplaceEditorButtons ()
{
  var p, frmMain, Grid, colorDlg;

  // Obtain the application process and its main form
  p = Sys.Process("GridMainDemo");
  frmMain = p.WinFormsObject("frmMain");
  frmMain.Activate();
  // Select the "Inplace Editors" demo
  frmMain.WinFormsObject("gcNavigations").WinFormsObject("navBarControl1").Groups.Item_2(2).SelectedLinkIndex = 1;
  // Obtain the grid control
  Grid = frmMain.WinFormsObject("panelControl1").WinFormsObject("gcContainer").WinFormsObject("InplaceEditors").WinFormsObject("gridControl1");

  // Click the editor's ellipsis button
  ClickCellButton (Grid, null, 11, "Value", 1);
  // Simulate actions in the "Color" dialog
  colorDlg = p.Window("#32770", "Color");
  colorDlg.Window("Button", "&Define Custom Colors >>").ClickButton();
  colorDlg.Window("Edit", "", 4).wText = "128";
  colorDlg.Window("Edit", "", 5).wText = "128";
  colorDlg.Window("Edit", "", 6).wText = "255";
  colorDlg.Window("Button", "OK").ClickButton();
}

function ClickCellButton (Grid, ViewObj, RowIndex, ColumnId, ButtonIndex)
{
  var Editor, bounds, x, y;

  // Select the cell
  if (strictEqual(ViewObj, null))
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);
  // Get the editor object
  Editor = Grid.FocusedView.ActiveEditor;

  // Determine the button coordinates
  bounds = Editor.ViewInfo.ButtonInfoById(ButtonIndex).Bounds;
  x = bounds.X + bounds.Width/2;
  y = bounds.Y + bounds.Height/2;

  // Get the window object corresponding to the editor
  Editor = Sys.WindowFromHandle (Editor.Handle);
  // Click on the button
  Editor.Click (x, y);
}

JScript

function TestClickInplaceEditorButtons ()
{
  var p, frmMain, Grid, colorDlg;

  // Obtain the application process and its main form
  p = Sys.Process("GridMainDemo");
  frmMain = p.WinFormsObject("frmMain");
  frmMain.Activate();
  // Select the "Inplace Editors" demo
  frmMain.WinFormsObject("gcNavigations").WinFormsObject("navBarControl1").Groups.Item_2(2).SelectedLinkIndex = 1;
  // Obtain the grid control
  Grid = frmMain.WinFormsObject("panelControl1").WinFormsObject("gcContainer").WinFormsObject("InplaceEditors").WinFormsObject("gridControl1");

  // Click the editor's ellipsis button
  ClickCellButton (Grid, null, 11, "Value", 1);
  // Simulate actions in the "Color" dialog
  colorDlg = p.Window("#32770", "Color");
  colorDlg.Window("Button", "&Define Custom Colors >>").ClickButton();
  colorDlg.Window("Edit", "", 4).wText = "128";
  colorDlg.Window("Edit", "", 5).wText = "128";
  colorDlg.Window("Edit", "", 6).wText = "255";
  colorDlg.Window("Button", "OK").ClickButton();
}

function ClickCellButton (Grid, ViewObj, RowIndex, ColumnId, ButtonIndex)
{
  var Editor, bounds, x, y;

  // Select the cell
  if (ViewObj == null)
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);
  // Get the editor object
  Editor = Grid.FocusedView.ActiveEditor;

  // Determine the button coordinates
  bounds = Editor.ViewInfo.ButtonInfoById(ButtonIndex).Bounds;
  x = bounds.X + bounds.Width/2;
  y = bounds.Y + bounds.Height/2;

  // Get the window object corresponding to the editor
  Editor = Sys.WindowFromHandle (Editor.Handle);
  // Click on the button
  Editor.Click (x, y);
}

Python

def TestClickInplaceEditorButtons ():

  # Obtain the application process and its main form
  p = Sys.Process("GridMainDemo")
  frmMain = p.WinFormsObject("frmMain")
  frmMain.Activate()
  # Select the "Inplace Editors" demo
  frmMain.WinFormsObject("gcNavigations").WinFormsObject("navBarControl1").Groups.Item_2(2).SelectedLinkIndex = 1
  # Obtain the grid control
  Grid = frmMain.WinFormsObject("panelControl1").WinFormsObject("gcContainer").WinFormsObject("InplaceEditors").WinFormsObject("gridControl1")

  # Click the editor's ellipsis button
  ClickCellButton (Grid, None, 11, "Value", 1)
  # Simulate actions in the "Color" dialog
  colorDlg = p.Window("#32770", "Color")
  colorDlg.Window("Button", "&Define Custom Colors >>").ClickButton()
  colorDlg.Window("Edit", "", 4).wText = "128"
  colorDlg.Window("Edit", "", 5).wText = "128"
  colorDlg.Window("Edit", "", 6).wText = "255"
  colorDlg.Window("Button", "OK").ClickButton()

def ClickCellButton (Grid, ViewObj, RowIndex, ColumnId, ButtonIndex):

  # Select the cell
  if (ViewObj == None):
    Grid.ClickCell (RowIndex, ColumnId)
  else:
    ViewObj.ClickCell (RowIndex, ColumnId)
  # Activate the in-place editor
  ActivateCellEditor (Grid)
  # Get the editor object
  Editor = Grid.FocusedView.ActiveEditor

  # Determine the button coordinates
  bounds = Editor.ViewInfo.ButtonInfoById(ButtonIndex).Bounds
  x = bounds.X + bounds.Width/2
  y = bounds.Y + bounds.Height/2

  # Get the window object corresponding to the editor
  Editor = Sys.WindowFromHandle (Editor.Handle)
  # Click on the button
  Editor.Click (x, y)

VBScript

Sub TestClickInplaceEditorButtons
  Dim p, frmMain, Grid, colorDlg

  ' Obtain the application process and its main form
  Set p = Sys.Process("GridMainDemo")
  Set frmMain = p.WinFormsObject("frmMain")
  frmMain.Activate
  ' Select the "Inplace Editors" demo
  frmMain.WinFormsObject("gcNavigations").WinFormsObject("navBarControl1").Groups.Item_2(2).SelectedLinkIndex = 1
  ' Obtain the grid control
  Set Grid = frmMain.WinFormsObject("panelControl1").WinFormsObject("gcContainer").WinFormsObject("InplaceEditors").WinFormsObject("gridControl1")

  ' Click the editor's ellipsis button
  Call ClickCellButton (Grid, Nothing, 11, "Value", 1)
  ' Simulate actions in the "Color" dialog
  Set colorDlg = p.Window("#32770", "Color")
  colorDlg.Window("Button", "&Define Custom Colors >>").ClickButton
  colorDlg.Window("Edit", "", 4).wText = "128"
  colorDlg.Window("Edit", "", 5).wText = "128"
  colorDlg.Window("Edit", "", 6).wText = "255"
  colorDlg.Window("Button", "OK").ClickButton
End Sub

Sub ClickCellButton (Grid, ViewObj, RowIndex, ColumnId, ButtonIndex)
  Dim Editor, bounds, x, y

  ' Select the cell
  If ViewObj Is Nothing Then
    Call Grid.ClickCell (RowIndex, ColumnId)
  Else
    Call ViewObj.ClickCell (RowIndex, ColumnId)
  End If
  ' Activate the in-place editor
  ActivateCellEditor (Grid)

  ' Get the editor object
  Set Editor = Grid.FocusedView.ActiveEditor

  ' Determine the button coordinates
  Set bounds = Editor.ViewInfo.ButtonInfoById(ButtonIndex).Bounds
  x = bounds.X + bounds.Width/2
  y = bounds.Y + bounds.Height/2

  ' Get the window object corresponding to the editor
  Set Editor = Sys.WindowFromHandle (Editor.Handle)
  ' Click on the button
  Call Editor.Click (x, y)
End Sub

DelphiScript

procedure ClickCellButton (Grid, ViewObj, RowIndex, ColumnId, ButtonIndex);
var Editor, bounds, x, y : OleVariant;
begin
  // Select the cell
  if ViewObj = nil then
    Grid.ClickCell (RowIndex, ColumnId)
  else
    ViewObj.ClickCell (RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);

  // Get the editor object
  Editor := Grid.FocusedView.ActiveEditor;

  // Determine the button coordinates
  bounds := Editor.ViewInfo.ButtonInfoById(ButtonIndex).Bounds;
  x := bounds.X + bounds.Width/2;
  y := bounds.Y + bounds.Height/2;

  // Get the window object corresponding to the editor
  Editor := Sys.WindowFromHandle (Editor.Handle);
  // Click on the button
  Editor.Click (x, y);
end;

procedure TestClickInplaceEditorButtons;
var p, frmMain, Grid, colorDlg : OleVariant;
begin
  // Obtain the application process and its main form
  p := Sys.Process('GridMainDemo');
  frmMain := p.WinFormsObject('frmMain');
  frmMain.Activate;
  // Select the 'Inplace Editors' demo
  frmMain.WinFormsObject('gcNavigations').WinFormsObject('navBarControl1').Groups.Item_2[2].SelectedLinkIndex := 1;
  // Obtain the grid control
  Grid := frmMain.WinFormsObject('panelControl1').WinFormsObject('gcContainer').WinFormsObject('InplaceEditors').WinFormsObject('gridControl1');

  // Click the editor's ellipsis button
  ClickCellButton (Grid, nil, 11, 'Value', 1);
  // Simulate actions in the "Color" dialog
  colorDlg := p.Window('#32770', 'Color');
  colorDlg.Window('Button', '&Define Custom Colors >>').ClickButton;
  colorDlg.Window('Edit', '', 4).wText := '128';
  colorDlg.Window('Edit', '', 5).wText := '128';
  colorDlg.Window('Edit', '', 6).wText := '255';
  colorDlg.Window('Button', 'OK').ClickButton;
end;

C++Script, C#Script

function TestClickInplaceEditorButtons ()
{
  var p, frmMain, Grid, colorDlg;

  // Obtain the application process and its main form
  p = Sys["Process"]("GridMainDemo");
  frmMain = p["WinFormsObject"]("frmMain");
  frmMain["Activate"]();
  // Select the "Inplace Editors" demo
  frmMain["WinFormsObject"]("gcNavigations")["WinFormsObject"]("navBarControl1")["Groups"]["Item_2"](2)["SelectedLinkIndex "]= 1;
  // Obtain the grid control
  Grid = frmMain["WinFormsObject"]("panelControl1")["WinFormsObject"]("gcContainer")["WinFormsObject"]("InplaceEditors")["WinFormsObject"]("gridControl1");

  // Click the editor's ellipsis button
  ClickCellButton (Grid, null, 11, "Value", 1);
  // Simulate actions in the "Color" dialog
  colorDlg = p["Window"]("#32770", "Color");
  colorDlg["Window"]("Button", "&Define Custom Colors >>")["ClickButton"]();
  colorDlg["Window"]("Edit", "", 4)["wText"] = "128";
  colorDlg["Window"]("Edit", "", 5)["wText"] = "128";
  colorDlg["Window"]("Edit", "", 6)["wText"] = "255";
  colorDlg["Window"]("Button", "OK")["ClickButton"]();
}

function ClickCellButton (Grid, ViewObj, RowIndex, ColumnId, ButtonIndex)
{
  var Editor, bounds, x, y;

  // Select the cell
  if (ViewObj == null)
    Grid["ClickCell"](RowIndex, ColumnId)
  else
    ViewObj["ClickCell"](RowIndex, ColumnId);
  // Activate the in-place editor
  ActivateCellEditor (Grid);
  // Get the editor object
  Editor = Grid["FocusedView"]["ActiveEditor"];

  // Determine the button coordinates
  bounds = Editor["ViewInfo"]["ButtonInfoById"](ButtonIndex)["Bounds"];
  x = bounds["X"] + bounds["Width"]/2;
  y = bounds["Y"] + bounds["Height"]/2;

  // Get the window object corresponding to the editor
  Editor = Sys["WindowFromHandle"](Editor["Handle"]);
  // Click on the button
  Editor["Click"](x, y);
}

Example

Below is an example that illustrates how you can work with certain types of in-place editors in the XtraGrid control. To change cell values, it uses the routines defined in the previous sections of this topic: SetCellSelectedItem, SetCellChecked, OpenDropDownEditor and others.

The example works with the GridTutorials application.

How to get the application

JavaScript, JScript

function Main ()
{
  var p, frmMain, Grid, Popup;

  // Obtain the application process and its main form
  p = Sys.Process("GridTutorials");
  frmMain = p.WinFormsObject("frmMain");
  frmMain.Activate();
  // Select the "Banded View Navigation" demo
  frmMain.WinFormsObject("gcNavigations").WinFormsObject("listBoxControl1").SelectedItem = "Banded View Navigation";
  // Obtain the grid object
  Grid = frmMain.WinFormsObject("pcMain").WinFormsObject("gcContainer").WinFormsObject("Form1").WinFormsObject("gridControl1");

  // Modify the 1st record data
  SetCellSelectedItem (Grid, null, 0, "Category", "Saloon");
  SetCellChecked (Grid, null, 0, "In Stock?", false);
  SetCellRadioButton (Grid, null, 0, "Automatic Transmission", "No");
  DoCellSpinUp (Grid, null, 0, "Cyl", 3);
  // Open the dropdown calendar
  Popup = OpenDropDownEditor (Grid, null, 0, "Delivery Date");
  // Click the "Today" button (this will automatically close the editor)
  Popup.WinFormsObject("DateEditCalendar", "").WinFormsObject("SimpleButton", "Today").Click();

  // Modify the 2nd record data
  SetCellSelectedItem (Grid, null, 1, "Category", 2);
  SetCellChecked (Grid, null, 1, "In Stock?", true);
  SetCellRadioButton (Grid, null, 1, "Automatic Transmission", "No");
  DoCellSpinDown (Grid, null, 1, "# of Gears", 2);
  // Simulate keystrokes in the dropdown calculator
  Popup = OpenDropDownEditor (Grid, null, 1, "Price");
  Popup.Keys ("+1250=");
  aqUtils.Delay (1500);
  CancelDropDownEditor (Grid);  // Cancel the changes
}

Python

def Main ():

  # Obtain the application process and its main form
  p = Sys.Process("GridTutorials")
  frmMain = p.WinFormsObject("frmMain")
  frmMain.Activate()
  # Select the "Banded View Navigation" demo
  frmMain.WinFormsObject("gcNavigations").WinFormsObject("listBoxControl1").SelectedItem = "Banded View Navigation"
  # Obtain the grid object
  Grid = frmMain.WinFormsObject("pcMain").WinFormsObject("gcContainer").WinFormsObject("Form1").WinFormsObject("gridControl1")

  # Modify the 1st record data
  SetCellSelectedItem (Grid, None, 0, "Category", "Saloon")
  SetCellChecked (Grid, None, 0, "In Stock?", False)
  SetCellRadioButton (Grid, None, 0, "Automatic Transmission", "No")
  DoCellSpinUp (Grid, None, 0, "Cyl", 3)
  # Open the dropdown calendar
  Popup = OpenDropDownEditor (Grid, None, 0, "Delivery Date")
  # Click the "Today" button (this will automatically close the editor)
  Popup.WinFormsObject("DateEditCalendar", "").WinFormsObject("SimpleButton", "Today").Click()

  # Modify the 2nd record data
  SetCellSelectedItem (Grid, None, 1, "Category", 2)
  SetCellChecked (Grid, None, 1, "In Stock?", True)
  SetCellRadioButton (Grid, None, 1, "Automatic Transmission", "No")
  DoCellSpinDown (Grid, None, 1, "# of Gears", 2)
  # Simulate keystrokes in the dropdown calculator
  Popup = OpenDropDownEditor (Grid, None, 1, "Price")
  Popup.Keys ("+1250=")
  aqUtils.Delay (1500)
  CancelDropDownEditor (Grid)  # Cancel the changes

VBScript

Sub Main
  Dim p, frmMain, Grid, Popup

  ' Obtain the application process and its main form
  Set p = Sys.Process("GridTutorials")
  Set frmMain = p.WinFormsObject("frmMain")
  frmMain.Activate
  ' Select the "Banded View Navigation" demo
  frmMain.WinFormsObject("gcNavigations").WinFormsObject("listBoxControl1").SelectedItem = "Banded View Navigation"
  ' Obtain the grid object
  Set Grid = frmMain.WinFormsObject("pcMain").WinFormsObject("gcContainer").WinFormsObject("Form1").WinFormsObject("gridControl1")

  ' Modify the 1st record data
  Call SetCellSelectedItem (Grid, Nothing, 0, "Category", "Saloon")
  Call SetCellChecked (Grid, Nothing, 0, "In Stock?", False)
  Call SetCellRadioButton (Grid, Nothing, 0, "Automatic Transmission", "No")
  Call DoCellSpinUp (Grid, Nothing, 0, "Cyl", 3)
  ' Open the dropdown calendar
  Set Popup = OpenDropDownEditor (Grid, Nothing, 0, "Delivery Date")
  ' Click the "Today" button (this will automatically close the editor)
  Popup.WinFormsObject("DateEditCalendar", "").WinFormsObject("SimpleButton", "Today").Click

  ' Modify the 2nd record data
  Call SetCellSelectedItem (Grid, Nothing, 1, "Category", 2)
  Call SetCellChecked (Grid, Nothing, 1, "In Stock?", True)
  Call SetCellRadioButton (Grid, Nothing, 1, "Automatic Transmission", "No")
  Call DoCellSpinDown (Grid, Nothing, 1, "# of Gears", 2)
  ' Simulate keystrokes in the dropdown calculator
  Set Popup = OpenDropDownEditor (Grid, Nothing, 1, "Price")
  Popup.Keys ("+1250=")
  aqUtils.Delay (1500)
  CancelDropDownEditor (Grid)  ' Cancel the changes
End Sub

DelphiScript

procedure Main;
var p, frmMain, Grid, Popup : OleVariant;
begin
  // Obtain the application process and its main form
  p := Sys.Process('GridTutorials');
  frmMain := p.WinFormsObject('frmMain');
  frmMain.Activate;
  // Select the 'Banded View Navigation' demo
  frmMain.WinFormsObject('gcNavigations').WinFormsObject('listBoxControl1').SelectedItem := 'Banded View Navigation';
  // Obtain the grid object
  Grid := frmMain.WinFormsObject('pcMain').WinFormsObject('gcContainer').WinFormsObject('Form1').WinFormsObject('gridControl1');

  // Modify the 1st record data
  SetCellSelectedItem (Grid, nil, 0, 'Category', 'Saloon');
  SetCellChecked (Grid, nil, 0, 'In Stock?', false);
  SetCellRadioButton (Grid, nil, 0, 'Automatic Transmission', 'No');
  DoCellSpinUp (Grid, nil, 0, 'Cyl', 3);
  // Open the dropdown calendar
  Popup := OpenDropDownEditor (Grid, nil, 0, 'Delivery Date');
  // Click the 'Today' button (this will automatically close the editor)
  Popup.WinFormsObject('DateEditCalendar', '').WinFormsObject('SimpleButton', 'Today').Click;

  // Modify the 2nd record data
  SetCellSelectedItem (Grid, nil, 1, 'Category', 2);
  SetCellChecked (Grid, nil, 1, 'In Stock?', true);
  SetCellRadioButton (Grid, nil, 1, 'Automatic Transmission', 'No');
  DoCellSpinDown (Grid, nil, 1, '# of Gears', 2);
  // Simulate keystrokes in the dropdown calculator
  Popup := OpenDropDownEditor (Grid, nil, 1, 'Price');
  Popup.Keys ('+1250=');
  aqUtils.Delay (1500);
  CancelDropDownEditor (Grid);  // Cancel the changes
end;

C++Script, C#Script

function Main ()
{
  var p, frmMain, Grid, Popup;

  // Obtain the application process and its main form
  p = Sys["Process"]("GridTutorials");
  frmMain = p["WinFormsObject"]("frmMain");
  frmMain["Activate"]();
  // Select the "Banded View Navigation" demo
  frmMain["WinFormsObject"]("gcNavigations")["WinFormsObject"]("listBoxControl1")["SelectedItem"] = "Banded View Navigation";
  // Obtain the grid object
  Grid = frmMain["WinFormsObject"]("pcMain")["WinFormsObject"]("gcContainer")["WinFormsObject"]("Form1")["WinFormsObject"]("gridControl1");

  // Modify the 1st record data
  SetCellSelectedItem (Grid, null, 0, "Category", "Saloon");
  SetCellChecked (Grid, null, 0, "In Stock?", false);
  SetCellRadioButton (Grid, null, 0, "Automatic Transmission", "No");
  DoCellSpinUp (Grid, null, 0, "Cyl", 3);
  // Open the dropdown calendar
  Popup = OpenDropDownEditor (Grid, null, 0, "Delivery Date");
  // Click the "Today" button (this will automatically close the editor)
  Popup["WinFormsObject"]("DateEditCalendar", "")["WinFormsObject"]("SimpleButton", "Today")["Click"]();

  // Modify the 2nd record data
  SetCellSelectedItem (Grid, null, 1, "Category", 2);
  SetCellChecked (Grid, null, 1, "In Stock?", true);
  SetCellRadioButton (Grid, null, 1, "Automatic Transmission", "No");
  DoCellSpinDown (Grid, null, 1, "# of Gears", 2);
  // Simulate keystrokes in the dropdown calculator
  Popup = OpenDropDownEditor (Grid, null, 1, "Price");
  Popup["Keys"]("+1250=");
  aqUtils["Delay"](1500);
  CancelDropDownEditor (Grid);  // Cancel the changes
}

See Also

Working With Developer Express XtraGrid
Accessing Views in Developer Express XtraGrid
Activating and Closing In-place Editors in Developer Express XtraGrid
Obtaining and Setting Cell Values in Developer Express XtraGrid
Selecting Cells in Developer Express XtraGrid

Highlight search results