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

Update node label position

Thread ID:

Created:

Updated:

Platform:

Replies:

96737 Oct 1,2010 03:15 PM UTC Oct 5,2010 01:13 PM UTC WinForms 1
loading
Tags: Diagram
Witold Slirz
Asked On October 1, 2010 03:15 PM UTC

Hi,
Im using this code to calculate node's label position:

label.Position = Position.Custom;
label.OffsetX = node.Size.Width / 2;
label.OffsetY = node.Size.Height + 20;

How to recalculate label position automatically when user resize node?


Pandi Murugan A [Syncfusion]
Replied On October 5, 2010 01:13 PM UTC

Hi Witold,

Thank you for your interest in Syncfusion Products.

We suggest you to use Diagram DocumentEventSink's SizeChanged event to update the Node's Label position. Please refer the below code snippet.


[C#]
public Form1()
{
InitializeComponent();
((DocumentEventSink)diagram1.Model.EventSink).SizeChanged+=new SizeChangedEventHandler(Form1_SizeChanged);
}

void Form1_SizeChanged(SizeChangedEventArgs evtArgs)
{
//update the label position here
PathNode node = evtArgs.NodeAffected as PathNode;
if (node.Labels.Count > 0)
if (node.Labels[0] != null)
{
node.Labels[0].OffsetX = node.Size.Width / 2;
node.Labels[0].OffsetY = node.Size.Height + 20;
}
}


For your convenience, we have created a simple sample and the same can be downloaded from below link.

LabelPosition648179222.zip

Please let me know if you have any concerns.

Regards,
Pandi Murugan A



CONFIRMATION

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.

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

;