We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Image in the middle of the link?

Thread ID:





57874 Mar 13,2007 01:09 PM UTC Mar 20,2007 06:11 PM UTC WinForms 4
Tags: Diagram
Administrator [Syncfusion]
Asked On March 13, 2007 01:09 PM UTC

I'd like to add a small image, like EndPointDecorator (for example, DiamondDecorator), but at the middle of the link line( i'm using my own link tool class based on DirectedLineLinkTool).
What is the simplest way to add such image ?

J.Nagarajan [Syncfusion]
Replied On March 13, 2007 05:56 PM UTC

Hi Ok,

You can add a small image (DiamondDecorator) at the middle of the link line. You can use the following code snippet to achieve this.

LinkCmd newlink= new LinkCmd();
Link link= new Link(Link.Shapes.Line);
newlink.SourcePort = symbol.CenterPort;
newlink.TargetPort = rrect.CenterPort;

InsertNodesCmd cmd=new InsertNodesCmd();
BitmapNode bitmap=new BitmapNode("..\\..\\Image.gif");
bitmap.X= link.X+link.Width/2;

I have attached the sample for your reference. In this sample you can add symbols by clicking on the "Add Symbols" button. When you click on the Link button a link should be created and you can see the image at the middle of this link.

You can download this sample from the following page.

Please refer to it and let me know if you have any questions.


Thanks for using Syncfusion product.


Administrator [Syncfusion]
Replied On March 14, 2007 07:01 AM UTC

Thanks for your sample, though it has one disadvatage: when link is moved during symbol moving the bitmap remained in old place.

J.Nagarajan [Syncfusion]
Replied On March 15, 2007 11:24 PM UTC

Hi Ok,

Thanks for you for being patience.

The bitmap gets placed in the middle of the link when link is moved. But we have a minar problem in bitmap alignment. We will resolve this issue and I will get back to you with more details at the earliest.


J.Nagarajan [Syncfusion]
Replied On March 20, 2007 06:11 PM UTC

Hi Ok,

Sorry for the delay in getting back to you.

You can handle NodeMoved and Bounds changed events to position the bitmap at the center of the link.

BitmapNode bitmap;
Link link;
private void diagram1_NodeMoved(object sender, Syncfusion.Windows.Forms.Diagram.MoveEventArgs evtArgs)
bitmap.X= link.X+link.Width/2-bitmap.Width/2;

private void diagram1_BoundsChanged(object sender, Syncfusion.Windows.Forms.Diagram.BoundsEventArgs evtArgs)
bitmap.X= link.X+link.Width/2-bitmap.Width/2;

I have attached the sample for your reference. Please download the sample from the following page.

http://websamples.syncfusion.com/samples/Diagram.Windows/Image On Link/main.htm

Let me know if you have any questions.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon