InsertRow(Index: Integer, Value: ConditionOperatorType): IListViewItem;
None;
Index. Index, by which element is added.
Value. The statement that will be used in the expression when the element to be added is grouped with another component element.
The InsertRow method adds an element by the specified index.
The element is added with the specified expression by the specified index before the element contained before adding the new element.
NOTE. The element cannot be added after all the elements in the component.
To add an element after all the component elements, use the ICtrlGroupConditions.AddRow method.
To group the selected elements, use the ICtrlGroupConditions.Group method.
To group elements by index, use the ICtrlGroupConditions.GroupByIndexes method.
To execute the example, create a form given in the example for the ICtrlGroupConditions.AddRow method. Add two Button components named Button1 and Button2 to the form. For the Button1 component, set the Text property to Add Element and Groups, for the Button2 component, set the property to Ungroup All Groups.
Add a link to the Forms system assembly.
The example is a handler of the OnClick events for the Button1 and Button2 components.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
AttrEditBox, AttrEditBox2: IEditBox;
List: ITreeCombo;
ValueEdit: IIntegerEdit;
Items: IListViewItems;
Arr: Array Of Integer;
Begin
// Add a new element to the second row
CtrlGroupConditions1.InsertRow(1, ConditionOperatorType.Or_);
// Add a visual component for the Attribute column
AttrEditBox := New EditBox.Create;
AttrEditBox.Text := "VALUE";
CtrlGroupConditions1.InsertControl(AttrEditBox, 2, 1);
// Add a visual component for the Condition column
List := New TreeCombo.Create;
List.Nodes.Add(Null, "Equal").Selected := True;
List.Nodes.Add(Null, "Not equal");
List.Nodes.Add(Null, "Less");
List.Nodes.Add(Null, "Greater");
List.Nodes.Add(Null, "Less or equal");
List.Nodes.Add(Null, "Greater or equal");
List.SelectionMode := SelectionModeType.SingleSelect;
CtrlGroupConditions1.InsertControl(List, 3, 1);
// Add a visual component for the Value column
ValueEdit := New IntegerEdit.Create;
ValueEdit.Value := 15;
CtrlGroupConditions1.InsertControl(ValueEdit, 4, 1);
// Set array for the first group
Arr := New Integer[2];
Arr[0] := 0;
Arr[1] := 1;
// Group elements
CtrlGroupConditions1.GroupByIndexes(Arr);
// Get component elements
Items := CtrlGroupConditions1.Items;
// Select elements for the second group
Items.Item(2).Checked := True;
Items.Item(3).Checked := True;
// Group elements
CtrlGroupConditions1.Group;
End Sub Button1OnClick;
Sub Button2OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Groups: IConditionGroups;
Group: IConditionGroup;
Elements: IConditionElements;
Element: IConditionElement;
GCount, ECount, i, j, s: Integer;
Arr : Array Of Integer;
Begin
// Get groups of elements
Groups := CtrlGroupConditions1.Groups;
// Get number of groups
GCount := Groups.Count;
For i := 0 To GCount - 1 Do
// Get group of elements
Group := Groups.Item(i);
// Get group elements
Elements := Group.Elements;
// Get number of elements
ECount := Elements.Count;
// Create array of elements
If ECount >= 2 Then
For j := 0 To ECount - 1 Do
Arr := New integer[ECount];
For s := 0 To ECount - 1 Do
Element := Elements.Item(s);
Arr[s] := Element.Row;
End For;
End For;
// Ungroup all groups of elements
CtrlGroupConditions1.UngroupByIndexes(Arr);
End If;
End For;
End Sub Button2OnClick;
None.
After executing the example, the following buttons are added to the form: for adding a new element after the first row, for grouping elements and for ungrouping all groups of elements.
Clicking the Add Element and Groups button adds a new element after the first row and elements are grouped:
Clicking the Ungroup All Groups button ungroups all groups of elements:
See also: