Page 1 of 1

Programmatically delete annotation

Posted: Wed May 06, 2009 1:52 pm
by iansml
Hi,

Is there any way I can programmatically remove an annotation? I am able to hide it using:

Code: Select all

imageViewer1.SelectedAnnotation.Visible = false;
but it is still present in the ImageViewer.Annotations collection. I want it to be removed completely (like when I select an annotation and delete it manually using the delete key).

Thanks

Re: Programmatically delete annotation

Posted: Wed May 06, 2009 3:00 pm
by Alex
Hi Ian,

Thank you for your message. You can use the Remove method of the AnnotationCollection class. Here is an example:

Code: Select all

AnnotationBase annoToRemove = annotationViewer1.Annotations[imageIndex][indexOfAnnoToRemove];
annotationViewer1.Annotations[imageIndex].RemoveAt(annoToRemove);
We will redefine the RemoveAt method of the AnnotationCollection class in next version of library and it will work correctly.

Best regards, Alexander