Infragistics provides a variety of in-place editors that can be used in the UltraGrid control: text boxes, radio buttons, check boxes, and various drop-down editors. In the Obtaining and Setting Cell Values in Infragistics UltraGrid topic, we explained how to assign a value to any cell. However, you may need to modify the cell value using the cell editor, for example, enable the check box item, or simulate actions in the cell’s dropdown editor.
Before entering data into the grid cell, you need to select it and activate its in-place editor, and after you have modified the cell value, you need to close the editor committing changes. This topic describes how to access the cell’s editor, activate it and close the editor saving the changes made. It also describes how to deal with certain types of in-place editors.
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 |
Note: | In all of the samples below, the GetCell routine is used to obtain the UltraGridCell instance that represents the desired grid cell. This routine returns an object that corresponds to the grid cell specified by the row index and column index or name. You can find its code in the Accessing Grid Elements in Infragistics UltraGrid topic. |
Activating In-place Editors
In a UltraGrid control, selecting a cell does not activate the edit mode, although there is an exception to this rule. You can check the ability to enter the edit mode via UltraGridCell.CanEnterEditMode
. It returns False when, for example, the underlying data source or the column is read-only or when various activation and allow-edit related properties are set to not allow editing. To verify that a cell is in the edit state use the UltraGridCell.IsInEditMode
property.
To switch the cell into the edit mode you can simulate the F2 keystroke or call the grid’s native PerformAction
method with the “EnterEditMode” action type as the parameter.
Another technique that combines selecting a cell and activating its editor, works only when the corresponding column’s CellClickAction
property is set to Edit
. In this case a click on the desired cell selects it and enables the edit mode.
Example
JavaScript, JScript
function ActivateCellInplaceEditor (Grid, View, RowIndex, ColumnID)
{
var Cell;
// Obtain the cell and select it
Cell = GetCell (Grid, View, RowIndex, ColumnID);
Cell.Activate();
// Use any of the following statements to activate the edit mode --
// 1: Send the F2 keystroke
Grid.Keys ("[F2]");
// 2: Call the internal PerformAction method
// Grid.PerformAction ("EnterEditMode");
// 3: Click the cell. (This will work if the cell column's CellClickAction property is set to Edit)
// Cell.Click();
}
Python
def ActivateCellInplaceEditor (Grid, View, RowIndex, ColumnID):
# Obtain the cell and select it
Cell = GetCell (Grid, View, RowIndex, ColumnID)
Cell.Activate()
# Use any of the following statements to activate the edit mode --
# 1: Send the F2 keystroke
Grid.Keys ("[F2]")
# 2: Call the internal PerformAction method
# Grid.PerformAction ("EnterEditMode")
# 3: Click the cell. (This will work if the cell column's CellClickAction property is set to Edit)
# Cell.Click()
VBScript
Sub ActivateCellInplaceEditor (Grid, View, RowIndex, ColumnID)
Dim Cell
' Obtain the cell and select it
Set Cell = GetCell (Grid, View, RowIndex, ColumnID)
Cell.Activate
' Use any of the following statements to activate the edit mode --
' 1: Send the F2 keystroke
Grid.Keys ("[F2]")
' 2: Call the internal PerformAction method
' Grid.PerformAction("EnterEditMode")
' 3: Click the cell. (This will work if the cell column's CellClickAction property is set to Edit)
' Cell.Click
End Sub
DelphiScript
procedure ActivateCellInplaceEditor (Grid, View, RowIndex, ColumnID);
var Cell : OleVariant;
begin
// Obtain the cell and select it
Cell := GetCell (Grid, View, RowIndex, ColumnID);
Cell.Activate;
// Use any of the following statements to activate the edit mode --
// 1: Send the F2 keystroke
Grid.Keys ('[F2]');
// 2: Call the internal PerformAction method
// Grid.PerformAction ('EnterEditMode');
// 3: Click the cell. (This will work if the cell column's CellClickAction property is set to Edit)
// Cell.Click;
end;
C++Script, C#Script
function ActivateCellInplaceEditor (Grid, View, RowIndex, ColumnID)
{
var Cell;
// Obtain the cell and select it
Cell = GetCell (Grid, View, RowIndex, ColumnID);
Cell["Activate"]();
// Use any of the following statements to activate the edit mode --
// 1: Send the F2 keystroke
Grid["Keys"]("[F2]");
// 2: Call the internal PerformAction method
// Grid["PerformAction"]("EnterEditMode");
// 3: Click the cell. (This will work if the cell column's CellClickAction property is set to Edit)
// Cell["Click"]();
}
Accessing In-place Editors
After the cell editor is activated, you can modify the cell value. In most cases, you can successfully do this by assigning a new value to the cell. However, sometimes you may need to perform these actions over the embedded cell editor. The UltraGrid uses in-place editors that are data-aware versions of the stand-alone editors provided by Infragistics.
You can access any underlying editor through the UltraGridCell.Editor
property. If a cell has an associated editor this property returns an object that corresponds to the cell’s editor, otherwise the property returns an empty value. You can use the retrieved object to modify any of the properties available for the underlying editor. To check the editor type use the UltraGridCell.Editor.ClrClassName
property that denotes the object class name.
The table below lists the names of some frequently used in-place editors:
Class Name | Description |
---|---|
EditorWithText | Embedded text edit box. |
EditorWithMask | Embedded masked edit box. |
EditorWithCombo | Embedded drop-down combo box. |
CheckEditor | Embedded check box editor. |
OptionSetEditor | Embedded radio button editor. |
DateTimeEditor | Embedded date-time picker. |
Some of the in-place editors can have drop-down elements where the user can set the cell value. You can verify whether the cell’s editor has these elements via the UltraGridCell.Editor.SupportsDropDown
property.
Closing In-place Editors
To finish editing the UltraGrid cell value and save any changes made, the user should press the Enter key, call the grid’s native PerformAction
method with the “ExitEditMode” action type or select another grid cell. You can simulate the Enter keypress using the Keys
action.
The following code snippet contains the CloseCellEditor
routine that can be used to save changes made to a grid cell. The Grid parameter of this routine specifies the grid control under which the action is performed:
JavaScript, JScript
function CloseCellEditor (Grid)
{
// Use any of the following statements to disable the edit mode --
// 1: Send the Enter keystroke
Grid.Keys ("[Enter]");
// 2: Call the internal PerformAction method
// Grid.PerformAction ("ExiEditMode");
}
Python
def CloseCellEditor (Grid):
# Use any of the following statements to disable the edit mode --
# 1: Send the Enter keystroke
Grid.Keys ("[Enter]")
# 2: Call the internal PerformAction method
# Grid.PerformAction ("ExiEditMode")
VBScript
Sub CloseCellEditor (Grid)
' Use any of the following statements to disable the edit mode --
' 1: Send the Enter keystroke
Grid.Keys ("[Enter]")
' 2: Call the internal PerformAction method
' Grid.PerformAction("ExitEditMode")
End Sub
DelphiScript
procedure CloseCellEditor (Grid);
begin
// Use any of the following statements to disable the edit mode --
// 1: Send the Enter keystroke
Grid.Keys ('[Enter]');
// 2: Call the internal PerformAction method
// Grid.PerformAction ('ExitEditMode');
end;
C++Script, C#Script
function CloseCellEditor (Grid)
{
// Use any of the following statements to disable the edit mode --
// 1: Send the Enter keystroke
Grid["Keys"]("[Enter]");
// 2: Call the internal PerformAction method
// Grid["PerformAction"]("ExitEditMode");
}
You may also need to cancel the editing and discard any changes made to the cell. This happens when the user presses Esc.
To simulate the Esc key press, use the Keys
action. The CancelEditing
routine in the code snippet below demonstrates how to do this:
JavaScript, JScript
function CancelEditing (Grid)
{
Grid.Keys ("[Esc]");
}
Python
def CancelEditing (Grid):
Grid.Keys ("[Esc]")
VBScript
Sub CancelEditing (Grid)
Grid.Keys "[Esc]"
End Sub
DelphiScript
procedure CancelEditing (Grid);
begin
Grid.Keys ('[Esc]');
end;
C++Script, C#Script
function CancelEditing (Grid)
{
Grid["Keys"] ("[Esc]");
}
Working With Text Editors
The easiest way to change the value of a text box cell or any other editor that permits keyboard input, is to “type” the desired text into it. To do that, use the Keys
action. The general sequence of actions should include selecting the cell, activating its in-place editor, highlighting the previous value of a cell, typing the new value and saving the changes. The TypeToCell
routine in the following example illustrates how this can be done.
Example
JavaScript, JScript
function TypeToCell (Grid, View, RowIndex, ColumnID, NewText)
{
var Cell = GetCell(Grid, View, RowIndex, ColumnID);
if (! Cell.IsInEditMode)
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
Grid.Keys ("^a" + NewText);
CloseCellEditor (Grid);
}
Python
def TypeToCell (Grid, View, RowIndex, ColumnID, NewText):
Cell = GetCell(Grid, View, RowIndex, ColumnID)
if not Cell.IsInEditMode:
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID)
Grid.Keys ("^a" + NewText)
CloseCellEditor (Grid)
VBScript
Sub TypeToCell (Grid, View, RowIndex, ColumnID, NewText)
Dim Cell
Set Cell = GetCell(Grid, View, RowIndex, ColumnID)
If Not Cell.IsInEditMode Then
Call ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID)
End If
Call Grid.Keys ("^a" & NewText)
Call CloseCellEditor (Grid)
End Sub
DelphiScript
function TypeToCell (Grid, View, RowIndex, ColumnID, NewText);
var Cell: Variant;
begin
Cell := GetCell(Grid, View, RowIndex, ColumnID);
if not Cell.IsInEditMode then
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
Grid.Keys ('^a' + NewText);
CloseCellEditor (Grid);
end;
C++Script, C#Script
function TypeToCell (Grid, View, RowIndex, ColumnID, NewText)
{
var Cell = GetCell(Grid, View, RowIndex, ColumnID);
if (! Cell["IsInEditMode"])
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
Grid["Keys"] ("^a" + NewText);
CloseCellEditor (Grid);
}
Another way to change the cell value is to paste it from the clipboard. To learn how you can simulate the corresponding user actions, see Copying and Pasting Cell Values in Infragistics UltraGrid.
Working With RadioGroup Editors
A radio button represents an option that can have only one of two possible values. These options are called to be mutually exclusive. Single radio buttons are generally used to represent Boolean values. Radio buttons can be organized into groups (named radio groups) which define sets containing more than two mutually exclusive options. That is, in a radio group of N options only one option can be selected.
The cells with a radio button or radio group in-place editor can be identified by the value of the Editor.ClrClassName
property, which is equal to OptionSetEditor
. The editor object of this class has a FocusedIndex
property that specifies the index (starting from zero) of the focused item. To change the currently selected item you should move the focus to the desired item and then simulate a space bar stroke to select the item.
The SetRadioButtonEditorValue
routine below demonstrates how to modify a value of a cell that is represented as a radio group.
Example
JavaScript
function SetRadioButtonEditorValue(Grid, View, RowIndex, ColumnID, NewRadioButtonIndex)
{
// Locate and focus the desired cell
var Cell = GetCell(Grid, View, RowIndex, ColumnID);
if (! Cell.IsInEditMode)
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that in-place editor is a radio group
if (equal(Cell.Editor.ClrClassName, "OptionSetEditor"))
{
// Move focus to specified radio button
Cell.Editor.FocusedIndex = NewRadioButtonIndex;
// Select the radio button
Grid.Keys(" ");
}
}
JScript
function SetRadioButtonEditorValue(Grid, View, RowIndex, ColumnID, NewRadioButtonIndex)
{
// Locate and focus the desired cell
var Cell = GetCell(Grid, View, RowIndex, ColumnID);
if (! Cell.IsInEditMode)
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that in-place editor is a radio group
if (Cell.Editor.ClrClassName == "OptionSetEditor")
{
// Move focus to specified radio button
Cell.Editor.FocusedIndex = NewRadioButtonIndex;
// Select the radio button
Grid.Keys(" ");
}
}
Python
def SetRadioButtonEditorValue(Grid, View, RowIndex, ColumnID, NewRadioButtonIndex):
# Locate and focus the desired cell
Cell = GetCell(Grid, View, RowIndex, ColumnID)
if not Cell.IsInEditMode:
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID)
# Verify that in-place editor is a radio group
if (Cell.Editor.ClrClassName == "OptionSetEditor"):
# Move focus to specified radio button
Cell.Editor.FocusedIndex = NewRadioButtonIndex
# Select the radio button
Grid.Keys(" ")
VBScript
Sub SetRadioButtonEditorValue(Grid, View, RowIndex, ColumnID, NewRadioButtonIndex)
' Locate and focus the desired cell
Set Cell = GetCell(Grid, View, RowIndex, ColumnID)
If Not Cell.IsInEditMode Then
Call ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID)
End If
' Verify that in-place editor is a radio group
If Cell.Editor.ClrClassName = "OptionSetEditor" Then
' Move focus to specified radio button
Cell.Editor.FocusedIndex = NewRadioButtonIndex
' Select the radio button
Grid.Keys(" ")
End If
End Sub
DelphiScript
procedure SetRadioButtonEditorValue(Grid, View, RowIndex, ColumnID, NewRadioButtonIndex);
var
Cell: Variant;
begin
// Locate and focus the desired cell
Cell := GetCell(Grid, View, RowIndex, ColumnID);
if not Cell.IsInEditMode then
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that in-place editor is a radio group
if Cell.Editor.ClrClassName = 'OptionSetEditor' then
begin
// Move focus to specified radio button
Cell.Editor.FocusedIndex := NewRadioButtonIndex;
// Select the radio button
Grid.Keys(' ');
end;
end;
C++Script, C#Script
function SetRadioButtonEditorValue(Grid, View, RowIndex, ColumnID, NewRadioButtonIndex)
{
// Locate and focus the desired cell
var Cell = GetCell(Grid, View, RowIndex, ColumnID);
if (! Cell["IsInEditMode"])
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that in-place editor is a radio group
if (Cell["Editor"]["ClrClassName"] == "OptionSetEditor")
{
// Move focus to specified radio button
Cell["Editor"]["FocusedIndex"]= NewRadioButtonIndex;
// Select the radio button
Grid["Keys"](" ");
}
}
Working With CheckBox Editors
A check box is similar to a radio button. A single check box, represents an option which can have two or three states. A group of check boxes can represent a set of options that do not depend on each other and can be chosen simultaneously.
For the cells containing a check box editor the value of the Editor.ClrClassName
property is equal to CheckEditor
. The current state of the editor is defined by the CheckState
property. As stated above, an individual check box can have up to three states, they are: Checked, Unchecked and Indeterminate. The indeterminate state is available if the editor’s property ThreeState
is set to true and denotes a state when the option’s state is unknown.
The SetCheckBoxEditorValue
routine below demonstrates how to change a value of a cell that is displayed as a check box.
Example
JavaScript
function SetCheckBoxEditorValue(Grid, View, RowIndex, ColumnID, NewState)
{
// Locate and focus the desired cell
let Cell = GetCell (Grid, ChildBand, RowIndex, ColumnId);
if (! Cell.IsInEditMode)
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that in-place editor is a check box
if (equal(Cell.Editor.ClrClassName, "CheckEditor"))
// Verify the new value and set the corresponding state
switch (NewState)
{
case true : Cell.Editor.CheckState = "Checked"; break;
case false : Cell.Editor.CheckState = "Unchecked"; break;
default : if (Cell.Editor.ThreeState)
Cell.Editor.CheckState = "Indeterminate";
}
}
JScript
function SetCheckBoxEditorValue(Grid, View, RowIndex, ColumnID, NewState)
{
// Locate and focus the desired cell
var Cell = GetCell (Grid, ChildBand, RowIndex, ColumnId);
if (! Cell.IsInEditMode)
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that in-place editor is a check box
if (Cell.Editor.ClrClassName == "CheckEditor")
// Verify the new value and set the corresponding state
switch (NewState)
{
case true : Cell.Editor.CheckState = "Checked"; break;
case false : Cell.Editor.CheckState = "Unchecked"; break;
default : if (Cell.Editor.ThreeState)
Cell.Editor.CheckState = "Indeterminate";
}
}
Python
def SetCheckBoxEditorValue(Grid, View, RowIndex, ColumnID, NewState):
# Locate and focus the desired cell
Cell = GetCell (Grid, ChildBand, RowIndex, ColumnId)
if not Cell.IsInEditMode:
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID)
# Verify that in-place editor is a check box
if (Cell.Editor.ClrClassName == "CheckEditor"):
# Verify the new value and set the corresponding state
if NewState:
Cell.Editor.CheckState = "Checked"
elif not NewState:
Cell.Editor.CheckState = "Unchecked"
else:
if Cell.Editor.ThreeState:
Cell.Editor.CheckState = "Indeterminate"
VBScript
Sub SetCheckBoxEditorValue (Grid, View, RowIndex, ColumnID, NewState)
' Locate and focus the desired cell
Set Cell = GetCell (Grid, View, RowIndex, ColumnID)
If Not Cell.IsInEditMode Then
Call ActivateCellInplaceEditor (Grid, View, RowIndex, ColumnID)
End If
' Verify that in-place editor is a check box
If Cell.Editor.ClrClassName = "CheckEditor" Then
' Verify the new value and set the corresponding state
Select Case NewState
Case True Cell.Editor.CheckState = "Checked"
Case False Cell.Editor.CheckState = "Unchecked"
Case Else
If Cell.Editor.ThreeState Then
Cell.Editor.CheckState = "Indeterminate"
End If
End Select
End If
End Sub
DelphiScript
procedure SetCheckBoxEditorValue(Grid, View, RowIndex, ColumnID, NewState);
var Cell: OleVariant;
begin
// Locate and focus the desired cell
Cell := GetCell (Grid, ChildBand, RowIndex, ColumnId);
if not Cell.IsInEditMode then
ActivateCellInplaceEditor (Grid, View, RowIndex, ColumnID);
// Verify that in-place editor is a check box
if Cell.Editor.ClrClassName = 'CheckEditor' then
case NewState of
true : Cell.Editor.CheckState := 'Checked';
false : Cell.Editor.CheckState := 'Unchecked';
else
if Cell.Editor.ThreeState then
Cell.Editor.CheckState := 'Indeterminate'
end;
end;
C++Script, C#Script
function SetCheckBoxEditorValue(Grid, View, RowIndex, ColumnID, NewState)
{
// Locate and focus the desired cell
var Cell = GetCell (Grid, ChildBand, RowIndex, ColumnId);
if (! Cell["IsInEditMode"])
ActivateCellInplaceEditor (Grid, View, RowIndex, ColumnID);
// Verify that in-place editor is a check box
if (Cell["Editor"]["ClrClassName"] == "CheckEditor")
// Verify the new value and set the corresponding state
switch (NewState)
{
case true : Cell["Editor"]["CheckState"] = "Checked"; break;
case false : Cell["Editor"]["CheckState"] = "Unchecked"; break;
default : if (Cell["Editor"]["ThreeState"])
Cell["Editor"]["CheckState"] = "Indeterminate";
}
}
Working With Drop-Down Editors
A number of embedded in-place editors can have drop-down elements. These editors are combo boxes, date-time pickers, font-name selectors, color selectors, drop-down calculators and so on. These editors are more convenient, as the value is being chosen with the mouse, rather than being typed from the keyboard. Generally they are used to choose one or several items out of a list of predefined values. Some of these editors allow for the population of the list with custom values.
You can check the SupportsDropDown
Boolean property of the cell’s editor object to find out whether the editor has a drop-down element. On success you can use the editor’s methods DropDown
or CloseUp
to display or hide the drop-down element.
To change the item selected in the drop-down editor, you can set it to the editor’s Value
property. When the control represents some items from the predefined item list, you can also modify the SelectedIndex
property that specifies the zero-based index of the selected item.
Example
JavaScript, JScript
function OpenDropDownEditor(Grid, View, RowIndex, ColumnID)
{
// Locate and focus the desired cell
var Cell = GetCell(Grid, ChildBand, RowIndex, ColumnId);
if (! Cell.IsInEditMode)
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that the in-place editor can drop-down
if (Cell.Editor.SupportsDropDown)
Cell.Editor.DropDown;
}
function CloseDropDownEditor(Grid, View, RowIndex, ColumnID)
{
// Locate and focus the desired cell
var Cell = GetCell(Grid, ChildBand, RowIndex, ColumnId);
if (! Cell.IsInEditMode)
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that the in-place editor can drop-down
if (Cell.Editor.SupportsDropDown)
Cell.Editor.CloseUp;
}
function SetDropDownEditorValue(Grid, View, RowIndex, ColumnID, NewListIndex)
{
// Locate and focus the desired cell
var Cell = GetCell(Grid, ChildBand, RowIndex, ColumnId);
if (! Cell.IsInEditMode)
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that the in-place editor can drop-down
if (Cell.Editor.SupportsDropDown)
Cell.Editor.SelectedIndex = NewListIndex;
}
Python
def OpenDropDownEditor(Grid, View, RowIndex, ColumnID):
# Locate and focus the desired cell
Cell = GetCell(Grid, ChildBand, RowIndex, ColumnId)
if not Cell.IsInEditMode:
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID)
# Verify that the in-place editor can drop-down
if Cell.Editor.SupportsDropDown:
Cell.Editor.DropDown
def CloseDropDownEditor(Grid, View, RowIndex, ColumnID):
# Locate and focus the desired cell
Cell = GetCell(Grid, ChildBand, RowIndex, ColumnId)
if not Cell.IsInEditMode:
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID)
# Verify that the in-place editor can drop-down
if Cell.Editor.SupportsDropDown:
Cell.Editor.CloseUp
def SetDropDownEditorValue(Grid, View, RowIndex, ColumnID, NewListIndex):
# Locate and focus the desired cell
Cell = GetCell(Grid, ChildBand, RowIndex, ColumnId)
if not Cell.IsInEditMode:
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID)
# Verify that the in-place editor can drop-down
if (Cell.Editor.SupportsDropDown):
Cell.Editor.SelectedIndex = NewListIndex
VBScript
Sub OpenDropDownEditor(Grid, View, RowIndex, ColumnID)
' Locate and focus the desired cell
Set Cell = GetCell(Grid, View, RowIndex, ColumnID)
If Not Cell.IsInEditMode Then
Call ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID)
End If
' Verify that the in-place editor can drop-down
If Cell.Editor.SupportsDropDown Then
Cell.Editor.DropDown
End If
End Sub
Sub CloseDropDownEditor(Grid, View, RowIndex, ColumnID)
' Locate and focus the desired cell
Set Cell = GetCell(Grid, View, RowIndex, ColumnID)
If Not Cell.IsInEditMode Then
Call ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID)
End If
' Verify that the in-place editor can drop-down
If Cell.Editor.SupportsDropDown Then
Cell.Editor.CloseUp
End If
End Sub
Sub SetDropDownEditorValue(Grid, View, RowIndex, ColumnID, NewListIndex)
' Locate and focus the desired cell
Set Cell = GetCell(Grid, View, RowIndex, ColumnID)
If Not Cell.IsInEditMode Then
Call ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID)
End If
' Verify that the in-place editor can drop-down
If Cell.Editor.SupportsDropDown Then
Cell.Editor.SelectedIndex = NewListIndex
End If
End Sub
DelphiScript
procedure OpenDropDownEditor(Grid, View, RowIndex, ColumnID);
var
Cell: Variant;
begin
// Locate and focus the desired cell
Cell := GetCell(Grid, ChildBand, RowIndex, ColumnId);
if not Cell.IsInEditMode then
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that the in-place editor can drop-down
if Cell.Editor.SupportsDropDown then
Cell.Editor.DropDown;
end;
procedure CloseDropDownEditor(Grid, View, RowIndex, ColumnID);
var
Cell: Variant;
begin
// Locate and focus the desired cell
Cell := GetCell(Grid, ChildBand, RowIndex, ColumnId);
if not Cell.IsInEditMode then
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that the in-place editor can drop-down
if Cell.Editor.SupportsDropDown then
Cell.Editor.CloseUp;
end;
procedure SetDropDownEditorValue(Grid, View, RowIndex, ColumnID, NewListIndex);
var
Cell: Variant;
begin
// Locate and focus the desired cell
Cell := GetCell(Grid, ChildBand, RowIndex, ColumnId);
if not Cell.IsInEditMode then
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that the in-place editor can drop-down
if Cell.Editor.SupportsDropDown then
Cell.Editor.SelectedIndex := NewListIndex;
end;
C++Script, C#Script
function OpenDropDownEditor(Grid, View, RowIndex, ColumnID)
{
// Locate and focus the desired cell
var Cell = GetCell(Grid, ChildBand, RowIndex, ColumnId);
if (! Cell["IsInEditMode"])
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that the in-place editor can drop-down
if (Cell["Editor"]["SupportsDropDown"])
Cell["Editor"]["DropDown"];
}
function CloseDropDownEditor(Grid, View, RowIndex, ColumnID)
{
// Locate and focus the desired cell
var Cell = GetCell(Grid, ChildBand, RowIndex, ColumnId);
if (! Cell["IsInEditMode"])
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that the in-place editor can drop-down
if (Cell["Editor"]["SupportsDropDown"])
Cell["Editor"]["CloseUp"];
}
function SetDropDownEditorValue(Grid, View, RowIndex, ColumnID, NewListIndex)
{
// Locate and focus the desired cell
var Cell = GetCell(Grid, ChildBand, RowIndex, ColumnId);
if (! Cell["IsInEditMode"])
ActivateCellInplaceEditor(Grid, View, RowIndex, ColumnID);
// Verify that the in-place editor can drop-down
if (Cell["Editor"]["SupportsDropDown"])
Cell["Editor"]["SelectedIndex"] = NewListIndex;
}
Example
The sample below demonstrates how to deal with the cell’s in-place editors of certain types. This example works with the SamplesExplorer application that comes with the Infragistics NetAdvantage Suite. To change cell values, it uses the routines declared in previous sections of this topic: TypeToCell
, SetRadioButtonEditorValue
, SetCheckBoxEditorValue
and others.
JavaScript, JScript
function WorkingWithInplaceEditors()
{
var p1, w1, Grid;
// Obtain the application process
p1 = Sys.Process("SamplesExplorer");
// Select the "Per Cell ValueList and Editors" demo
p1.frmMain.WinFormsObject("tvwSamples").DblClickItem("|Feature Samples|V3 Per Cell ValueList and Editors");
w1 = p1.frmCellValueList.WinFormsObject("tabControl1");
// Switch to the "Per Cell Editor" tabbed page
w1.ClickTab("Per Cell Editor");
// Get the grid control
Grid = w1.tabPageCellEditor.panel2.ultraGrid2;
// Input to text cell
TypeToCell(Grid, null, 0, 1, "NewText");
// Select radio button
SetRadioButtonEditorValue(Grid, null, 9, 1, 0);
// Select check box item
SetCheckBoxEditorValue (Grid, null, 10, 1, true);
// Select combo box item
OpenDropDownEditor(Grid, null, 15, 1);
SetDropDownEditorValue(Grid, null, 15, 1, 2);
CloseDropDownEditor(Grid, null, 15, 1);
p1.frmCellValueList.Close();
}
Python
def WorkingWithInplaceEditors():
# Obtain the application process
p1 = Sys.Process("SamplesExplorer")
# Select the "Per Cell ValueList and Editors" demo
p1.frmMain.WinFormsObject("tvwSamples").DblClickItem("|Feature Samples|V3 Per Cell ValueList and Editors")
w1 = p1.frmCellValueList.WinFormsObject("tabControl1")
# Switch to the "Per Cell Editor" tabbed page
w1.ClickTab("Per Cell Editor")
# Get the grid control
Grid = w1.tabPageCellEditor.panel2.ultraGrid2
# Input to text cell
TypeToCell(Grid, None, 0, 1, "NewText")
# Select radio button
SetRadioButtonEditorValue(Grid, None, 9, 1, 0)
# Select check box item
SetCheckBoxEditorValue (Grid, None, 10, 1, True)
# Select combo box item
OpenDropDownEditor(Grid, None, 15, 1)
SetDropDownEditorValue(Grid, None, 15, 1, 2)
CloseDropDownEditor(Grid, None, 15, 1)
p1.frmCellValueList.Close()
VBScript
Sub WorkingWithInplaceEditors
Dim p1
Dim w1
Dim Grid
' Obtain the application process
Set p1 = Sys.Process("SamplesExplorer")
' Select the "Per Cell ValueList and Editors" demo
Call p1.frmMain.WinFormsObject("tvwSamples").DblClickItem("|Feature Samples|V3 Per Cell ValueList and Editors")
Set w1 = p1.frmCellValueList.WinFormsObject("tabControl1")
' Switch to the "Per Cell Editor" tabbed page
Call w1.ClickTab("Per Cell Editor")
' Get the grid control
Set Grid = w1.tabPageCellEditor.panel2.ultraGrid2
' Input to text cell
Call TypeToCell(Grid, Nothing, 0, 1, "NewText")
' Select radio button
Call SetRadioButtonEditorValue(Grid, Nothing, 9, 1, 0)
' Select check box item
Call SetCheckBoxEditorValue (Grid, Nothing, 10, 1, true)
' Select combo box item
Call OpenDropDownEditor(Grid, Nothing, 15, 1)
Call SetDropDownEditorValue(Grid, Nothing, 15, 1, 2)
Call CloseDropDownEditor(Grid, Nothing, 15, 1)
p1.frmCellValueList.Close
End Sub
DelphiScript
procedure WorkingWithInplaceEditors;
var p1, w1, Grid: OleVariant;
begin
// Obtain the application process
p1 := Sys.Process('SamplesExplorer');
// Select the "Per Cell ValueList and Editors" demo
p1.frmMain.WinFormsObject('tvwSamples').DblClickItem('|Feature Samples|V3 Per Cell ValueList and Editors');
w1 := p1.frmCellValueList.WinFormsObject('tabControl1');
// Switch to the "Per Cell Editor" tabbed page
w1.ClickTab('Per Cell Editor');
// Get the grid control
Grid := w1.tabPageCellEditor.panel2.ultraGrid2;
// Input to text cell
TypeToCell(Grid, nil, 0, 1, 'NewText');
// Select radio button
SetRadioButtonEditorValue(Grid, nil, 9, 1, 0);
// Select check box item
SetCheckBoxEditorValue (Grid, nil, 10, 1, True);
// Select combo box item
OpenDropDownEditor(Grid, nil, 15, 1);
SetDropDownEditorValue(Grid, nil, 15, 1, 2);
CloseDropDownEditor(Grid, nil, 15, 1);
p1.frmCellValueList.Close;
end;
C++Script, C#Script
function WorkingWithInplaceEditors()
{
var p1, w1, Grid;
// Obtain the application process
p1 = Sys["Process"]("SamplesExplorer");
// Select the "Per Cell ValueList and Editors" demo
p1["frmMain"]["WinFormsObject"]("tvwSamples")["DblClickItem"]("|Feature Samples|V3 Per Cell ValueList and Editors");
w1 = p1["frmCellValueList"]["WinFormsObject"]("tabControl1");
// Switch to the "Per Cell Editor" tabbed page
w1["ClickTab"]("Per Cell Editor");
// Get the grid control
Grid = w1["tabPageCellEditor"]["panel2"]["ultraGrid2"];
// Input to text cell
TypeToCell(Grid, null, 0, 1, "NewText");
// Select radio button
SetRadioButtonEditorValue(Grid, null, 9, 1, 0);
// Select check box item
SetCheckBoxEditorValue (Grid, null, 10, 1, true);
// Select combo box item
OpenDropDownEditor(Grid, null, 15, 1);
SetDropDownEditorValue(Grid, null, 15, 1, 2);
CloseDropDownEditor(Grid, null, 15, 1);
p1["frmCellValueList"]["Close"]();
}
See Also
Working With Infragistics UltraGrid
Selecting Cells in Infragistics UltraGrid
Obtaining and Setting Cell Values in Infragistics UltraGrid
Copying and Pasting Cell Values in Infragistics UltraGrid
Keys Action