Ungroups this
AnnGroupObject object.
Syntax
Visual Basic (Declaration) | |
---|
Public Sub Ungroup() |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As AnnGroupObject
instance.Ungroup()
|
C++/CLI | |
---|
public:
void Ungroup(); |
Example
This example groups/ungroups objects.
Visual Basic | Copy Code |
---|
Private Sub AnnGroupObject_Ungroup()
Dim container As AnnContainer = New AnnContainer()
Dim line As AnnLineObject = New AnnLineObject()
container.Children.Add(line)
Dim rect As AnnRectangleObject = New AnnRectangleObject()
container.Children.Add(rect)
Dim s As String = String.Format("There are {0} objects in the container", container.Children.Count)
MessageBox.Show(s)
Dim group As AnnGroupObject = New AnnGroupObject()
Do While container.Children.Count > 0
Dim obj As AnnObjectBase = CType(IIf(TypeOf container.Children(0) Is AnnObjectBase, container.Children(0), Nothing), AnnObjectBase)
container.Children.Remove(obj)
group.Children.Add(obj)
Loop
s = String.Format("There are {0} objects in the container", container.Children.Count)
MessageBox.Show(s)
container.Children.Add(group)
s = String.Format("There are {0} objects in the container", container.Children.Count)
MessageBox.Show(s)
group.Ungroup()
s = String.Format("There are {0} objects in the container", container.Children.Count)
MessageBox.Show(s)
container.Children.Remove(group)
s = String.Format("There are {0} objects in the container", container.Children.Count)
MessageBox.Show(s)
End Sub |
C# | Copy Code |
---|
private void AnnGroupObject_Ungroup() { AnnContainer container = new AnnContainer(); // adds a few objects to the container AnnLineObject line = new AnnLineObject(); container.Children.Add(line); AnnRectangleObject rect = new AnnRectangleObject(); container.Children.Add(rect); // show the number of objects in this container (should be 2: line and rectangle) string s = string.Format("There are {0} objects in the container", container.Children.Count); ; MessageBox.Show(s); // move all objects from the container to a group AnnGroupObject group = new AnnGroupObject(); while(container.Children.Count > 0) { AnnObjectBase obj = container.Children[0] as AnnObjectBase; container.Children.Remove(obj); group.Children.Add(obj); } // show the number of objects in this container (should be 0) s = string.Format("There are {0} objects in the container", container.Children.Count); MessageBox.Show(s); // add the group to the container container.Children.Add(group); // show the number of objects in this container (should be 1: group) s = string.Format("There are {0} objects in the container", container.Children.Count); MessageBox.Show(s); // ungroup the group object group.Ungroup(); // show the number of objects in this container (should be 3: group, line and rectangle) s = string.Format("There are {0} objects in the container", container.Children.Count); MessageBox.Show(s); // remove the group from the container container.Children.Remove(group); // show the number of objects in this container (should be 2: line and rectangle) s = string.Format("There are {0} objects in the container", container.Children.Count); MessageBox.Show(s); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family
See Also