Group;
The Group method groups selected elements.
Elements can be grouped if the component has at least two consequently selected elements that are not contained on other groups. To determine array of selected elements, use the ICtrlGroupConditions.SelectedRows property.
To determine whether elements can be grouped, use the ICtrlGroupConditions.CanGroup method.
To group elements by indexes, use the ICtrlGroupConditions.GroupByIndexes method.
To execute the example, create a form given in the example for the ICtrlGroupConditions.AddRow method. Add two Button component named Button1 and Button2 on the form. For the Button1 component, set the Text property to Group, for the Button2 component, set the property to Ungroup. Set the Enabled property to False for the components.
Add a link to the Forms system assembly.
The example is a handler of the OnChecked event for the CtrlGroupConditions1 component and a handler of the OnClick events for the Button1 and Button2 components.
Sub CtrlGroupConditions1OnChecked(Sender: Object; Args: IListViewItemEventArgs);
Var
Elements: Array Of Integer;
Begin
// Get selected elements
Elements := CtrlGroupConditions1.SelectedRows;
// Determine whether elements can be grouped
If CtrlGroupConditions1.CanGroup(Elements) Then
Button1.Enabled := True;
Else
Button1.Enabled := False;
End If;
// Determine whether group of elements can be ungrouped
If CtrlGroupConditions1.CanUngroup(Elements) Then
Button2.Enabled := True;
Else
Button2.Enabled := False;
End If;
End Sub CtrlGroupConditions1OnChecked;
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
// Group elements
CtrlGroupConditions1.Group;
End Sub Button1OnClick;
Sub Button2OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
// Ungroup group of elements
CtrlGroupConditions1.Ungroup;
End Sub Button2OnClick;
After executing the example, the following is added to the form: buttons for grouping selected elements and for ungrouping the selected group of elements. When elements are selected, it is determined whether buttons are available, for example:
Clicking the Group button groups the selected elements:
Clicking the Ungroup button ungroups the selected group of elements:
See also: