Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Textformat.alignment (Read 1682 times)
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Textformat.alignment
Oct 22nd, 2006 at 8:02pm
Print Post  
I want to set the text alignment of a box when the user clicks a toolbutton. So I used the following code in my click event.

Code
Select All
(flowChart.ActiveObject as Box).TextFormat.Alignment = StringAlignment.Near; 



But the box does not show any effect until I resize or move the box. Only then the text is aligned to the left side.

What is going wrong?

Dirk
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Textformat.alignment
Reply #1 - Oct 23rd, 2006 at 7:01am
Print Post  
StringFormat is a standard .NET class and FlowChart.NET cannot detect changes done to the StringFormat properties. You could either assign a whole StringFormat object to the Box.TextFormat, or explicitly call FlowChart.Invalidate after changing Box.TextFormat.Alignment.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Textformat.alignment
Reply #2 - Oct 23rd, 2006 at 7:04am
Print Post  
Invalidating won't be enough if using polygonal text layout or styled text, so it might be better to assign a new StringFormat object to the Box.TextFormat.

Stoyan
  
Back to top
 
IP Logged
 
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Re: Textformat.alignment
Reply #3 - Oct 23rd, 2006 at 7:50am
Print Post  
Perfect !

Here's my code for alignment left, in case others have the same problem:

Code
Select All
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Left;
format.LineAlignment = StringAlignment.Center;
(flowChart.ActiveObject as Box).TextFormat = format;
 



Thanks

Dirk
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint