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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Positioning a Label

Thread ID:

Created:

Updated:

Platform:

Replies:

70249 Dec 4,2007 08:40 AM UTC Dec 14,2007 07:10 AM UTC WinForms 7
loading
Tags: Diagram
Michael M.
Asked On December 4, 2007 08:40 AM UTC

I have a problem to position a label correctly. If i set a lables position Property for example to "BottomCenter" than the label is positioned half inside the container an half outside. I expected that the label appears on the bottom end of the container (not on the border of the container).

Kind regards,
Michi



positionLabel.zip

Sri Subhashini M [Syncfusion]
Replied On December 5, 2007 06:40 AM UTC

Hi Michi,

Sorry for delay getting back with you.

We can adjust the label position by setting the Position as Custom type. Then we have to set the Offset values for the X,Y co-ordinates to specify the label position.

Kindly review the code snippet

outerRect.Labels.Add(new Syncfusion.Windows.Forms.Diagram.Label());
outerRect.Labels[0].Text = "Rectangle";
outerRect.Labels[0].Position = Position.Custom;
outerRect.Labels[0].OffsetX = 50;
outerRect.Labels[0].OffsetY= 65;

Please take a look at the sample and let me know if its helpful.

http://websamples.syncfusion.com/samples/Diagram.Windows/70249/main.htm

Regards,
Suba



Michael M.
Replied On December 5, 2007 07:15 AM UTC

The problem with custom positioning is, that i allways need to recalulate the offset if i resize the node which contains the label.
For example if i want to have it aligned on the bottom center (all the time) of my node.

Is there any other solution to achieve my goal.

Regards
Michi


Sri Subhashini M [Syncfusion]
Replied On December 6, 2007 10:05 AM UTC

Hi Michi,

We can retain the labels offset value using the SizeChanged event. While resizing a node the SizeEvent gets fired. Using the event we can retain the labels position.

Please use the following code and let me know if this helpful.

// Adding Event Handler
((DocumentEventSink)diagram1.Model.EventSink).SizeChanged += new SizeChangedEventHandler(Form1_SizeChanged);

outerRect.Labels.Add(new Syncfusion.Windows.Forms.Diagram.Label());
outerRect.Labels[0].Text = "Rectangle";
outerRect.Labels[0].Position = Position.Custom;
outerRect.Labels[0].OffsetX = outerRect.Size.Width / 2;
outerRect.Labels[0].OffsetY = outerRect.Size.Height;

// Resizing
void Form1_SizeChanged(SizeChangedEventArgs evtArgs)
{
outerRect.Labels[0].OffsetX = outerRect.Size.Width / 2;
outerRect.Labels[0].OffsetY = outerRect.Size.Height;
}

Regards,
Suba



Michael M.
Replied On December 7, 2007 05:41 AM UTC

Hallo, thanks for your help but i have known this possibility before and i hopped that there is another way too, to achieve centering a label on the bottom end of a node.

If there isn't any other way, please inform me.

Regards
Michi


Sri Subhashini M [Syncfusion]
Replied On December 8, 2007 07:27 AM UTC

Hi Michi,

I apologize for the delay in responding.

I am able to understand your requirement, but fixing custom label positions for a node is not possible. Because the custom labels position is calculated with respective of the top left of the node. Once the node get resized we have to recalculate the offset position of the label using SizeChanged event.

Please let me know if you have any question.

Regards,
Suba


Michael M.
Replied On December 12, 2007 06:53 AM UTC

I am not happy about your answer. If i recalculate the position on every resize, i get refresh problems. For some times the label is not repositioned correct until i refresh it explicit.

Why your default positioning with TopCenter, BottomCenter positions the Label on the border of the node. I dont understand why you do this

regards
michi



Sri Subhashini M [Syncfusion]
Replied On December 14, 2007 07:10 AM UTC

Hi Michi,

Sorry for the delay in responding you.

For built-in Position we are calculating the labels position based on the size and location of the node. But for custom position it is not possible to calculate the position from size of the node. Since the custom position is calculated relative to the top left of the node. If we want to calculate the custom position relative to the node size as like built-in position, we need to add additional codes.

So we will consider "Diagram should calculate the label position respective to the node size" as a feature request. We have notified our development team on this regard and will get back to you once we hear back from them.

Regards,
Suba



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

;