Leadtools.Annotations Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.10.31
Tag Property
See Also  Example
Leadtools.Annotations Namespace > AnnObject Class : Tag Property




Gets or sets the tag of this AnnObject.

Syntax

Visual Basic (Declaration) 
Public Overridable Property Tag As Integer
Visual Basic (Usage)Copy Code
Dim instance As AnnObject
Dim value As Integer
 
instance.Tag = value
 
value = instance.Tag
C# 
public virtual int Tag {get; set;}
Managed Extensions for C++ 
public: __property virtual int get_Tag();
public: __property virtual void set_Tag( 
   int value
);
C++/CLI 
public:
virtual property int Tag {
   int get();
   void set (int value);
}

Return Value

And integer value that specifies the tag of this AnnObject.

Example

This sample adds a tag to each AnnObject added to the container

Visual BasicCopy Code
Private tagCount As Integer
Public Sub AnnObject_Tag()
   tagCount = 0
   ' create a container and subclass to its Objects.ItemAdded event
   Dim container As AnnContainer = New AnnContainer()
   AddHandler container.Objects.ItemAdded, AddressOf AnObjectAddedToContainer

   ' add a few objects to the container
   Dim lineObj As AnnLineObject = New AnnLineObject()
   container.Objects.Add(lineObj)

   Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
   container.Objects.Add(rectObj)

   Dim ellipseObj As AnnEllipseObject = New AnnEllipseObject()
   container.Objects.Add(ellipseObj)

   ' enumerate the objects in the container and show their tag
   For Each obj As AnnObject In container.Objects
      MessageBox.Show(String.Format("Object type: {0}, Tag: {1}", obj.GetType().Name, obj.Tag))
   Next obj
End Sub

Private Sub AnObjectAddedToContainer(ByVal sender As Object, ByVal e As RasterCollectionEventArgs(Of AnnObject))
   ' get the object
   Dim obj As AnnObject = e.Item

   ' update its tag
   obj.Tag = tagCount
   tagCount += 1
End Sub
C#Copy Code
private int tagCount; 
public void AnnObject_Tag() 

   tagCount = 0; 
   // create a container and subclass to its Objects.ItemAdded event 
   AnnContainer container = new AnnContainer(); 
   container.Objects.ItemAdded += new EventHandler<RasterCollectionEventArgs<AnnObject>>(AnObjectAddedToContainer); 
 
   // add a few objects to the container 
   AnnLineObject lineObj = new AnnLineObject(); 
   container.Objects.Add(lineObj); 
 
   AnnRectangleObject rectObj = new AnnRectangleObject(); 
   container.Objects.Add(rectObj); 
 
   AnnEllipseObject ellipseObj = new AnnEllipseObject(); 
   container.Objects.Add(ellipseObj); 
 
   // enumerate the objects in the container and show their tag 
   foreach(AnnObject obj in container.Objects) 
      MessageBox.Show(String.Format("Object type: {0}, Tag: {1}", obj.GetType().Name, obj.Tag)); 

 
private void AnObjectAddedToContainer(object sender, RasterCollectionEventArgs<AnnObject> e) 

   // get the object 
   AnnObject obj = e.Item; 
 
   // update its tag 
   obj.Tag = tagCount; 
   tagCount++; 
}

Remarks

The tag is an integer value that is not used by the LEADTOOLS Annotation toolkit. However, you can use the tag value to store any integer value you want. For example, you can use it store an index that links this AnnObject to other collections in your program.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Leadtools.Annotations requires a Document or Medical toolkit license and unlock key. For more information, refer to: Raster Pro/Document/Medical Features