←Select platform

Container Property

Summary

Gets or sets the AnnContainer that contains this AnnObject.

Syntax

C#
VB
C++
[XmlIgnoreAttribute()] 
public virtual AnnContainer Container { get; set; } 
  
Public Overridable Property Container As Leadtools.Annotations.AnnContainer 
public: 
virtual property Leadtools.Annotations.AnnContainer^ Container { 
   Leadtools.Annotations.AnnContainer^ get(); 
   void set (    Leadtools.Annotations.AnnContainer^ ); 
} 

Property Value

The AnnContainer that contains this AnnObject.

Remarks

An AnnObject can be part of one AnnContainer only at any given time.

When adding or removing objects to or from a container, you do not need to manually set this property to the container value: this operation is performed internally by the LEADTOOLS annotation toolkit. However, you can check the value of this property to determine the container to which a certain object currently belongs.

Example

This example creates two containers, adds an object to the first container then moves it to the second while checking the Container property of the object.

C#
VB
using Leadtools; 
using Leadtools.Annotations; 
using Leadtools.Codecs; 
using Leadtools.WinForms; 
using Leadtools.Drawing; 
 
public void AnnObject_Container() 
{ 
   // create 2 containers 
   AnnContainer firstContainer = new AnnContainer(); 
   firstContainer.Name = "First Container"; 
   AnnContainer secondContainer = new AnnContainer(); 
   secondContainer.Name = "Second Container"; 
 
   // add an object to the first container 
   AnnLineObject line = new AnnLineObject(); 
   line.Name = "Line1"; 
 
   // add the object to the first container 
   firstContainer.Objects.Add(line); 
   string s = string.Format("Container: {0}", line.Container.Name); 
   MessageBox.Show(s); 
 
   // move the object to the second container 
   firstContainer.Objects.Remove(line); 
   secondContainer.Objects.Add(line); 
   s = string.Format("Container: {0}", line.Container.Name); 
   MessageBox.Show(s); 
} 
Imports Leadtools 
Imports Leadtools.Annotations 
Imports Leadtools.Codecs 
Imports Leadtools.WinForms 
Imports Leadtools.Drawing 
 
Public Sub AnnObject_Container() 
   ' create 2 containers 
   Dim firstContainer As AnnContainer = New AnnContainer() 
   firstContainer.Name = "First Container" 
   Dim secondContainer As AnnContainer = New AnnContainer() 
   secondContainer.Name = "Second Container" 
 
   ' add an object to the first container 
   Dim line As AnnLineObject = New AnnLineObject() 
   line.Name = "Line1" 
 
   ' add the object to the first container 
   firstContainer.Objects.Add(line) 
   Dim s As String = String.Format("Container: {0}", line.Container.Name) 
   MessageBox.Show(s) 
 
   ' move the object to the second container 
   firstContainer.Objects.Remove(line) 
   secondContainer.Objects.Add(line) 
   s = String.Format("Container: {0}", line.Container.Name) 
   MessageBox.Show(s) 
End Sub 

Requirements

Target Platforms

See Also

Reference

AnnObject Class

AnnObject Members

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Annotations Assembly