Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 79
  • Last Modified:

Controlling Label placement on form when "Bold" is turned on?

Functionality exists in my application that allows users to control the look of the application, i.e. Font Color, Font Bold, etc.

The problem that I'm having is that in normal mode, everything is aligned looks fine, however, when I turn on the "Bold" property for all Labels, they become misaligned. Is there a way to prevent this so that they stay in their original positions?

I've tried setting the AutoSize property to False and giving them set size values based on the largest one. I've used the TextAlign property as well to make them RightCenter justified. None of this seems to work.

Thanks!
0
BlakeMcKenna
Asked:
BlakeMcKenna
  • 6
  • 5
1 Solution
 
rspahitzCommented:
Is this a web application or desktop?  For desktop, you have a lot more control, but you still have the classic problem of how to display things that have unpredictable sizes.
Often the answer is to ensure that as label sizes change, the adjacent related fields size accordingly. e.g. if a label size changes from 100 to 125, the an adjacent text box show move 25 to the right, which may cause something else to *its* right to have to move, etc.
Have you tried turning off the Anchor property (set to none)?
0
 
BlakeMcKennaAuthor Commented:
This is a Windows App. I tried setting the Anchor property to None and that didn't have any affect.
0
 
rspahitzCommented:
After Anchor is set to None, all of those fields will "float" around as the form is resized...that's probably not directly going to fix your problem, but could if the window is enlarged to allow the expanded bold text to show more.

The next step would be to add some code to the SizeChanged event (I think that's the name) for each label and maybe additional controls. In there you would add something like: TextBox1.Left = Label1.Left + Label1.Width + 25' 25=padding

Again, you may have to apply other shifts, which could be things like textbox LocationChanged
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
BlakeMcKennaAuthor Commented:
Is there a known formula and/or routine for Resizing controls when the Form size changes?
0
 
rspahitzCommented:
The closest is the Anchor property, but that has limited use.  If you turn off all sides, the control "floats".  If you anchor it on two opposite side (e.g. left and right) then the control resizes.
The biggest problem is that these do not interact very well with other components so you have to do the additional work yourself.
0
 
BlakeMcKennaAuthor Commented:
I'll try and play around with it...
0
 
BlakeMcKennaAuthor Commented:
I never got this to work so I'm not sure whether to delete the question or not!
0
 
rspahitzCommented:
Try setting the label's AutoSize = true then look use the AutoSizeChanged event to shift the text box, something like this:

TextBox1.Left = Label1.Right + 10 '(10=padding)

That might get you going so that the text box moves based on the width of the label, so if the label-bold changes the width, the textbox will move. However, understand that sometimes this can get annoying to uses so if may not be the optimal solution to this problem. You may want to allow your users to do their own version of an IDE (with field drag-and-drop), which will be a lot of work.
0
 
BlakeMcKennaAuthor Commented:
I may need to rethink this functionality altogether! You did get me thinking though of some possible resolutions.
0
 
rspahitzCommented:
Great!  This is definitely not a straightforward issue.  Good luck in finding the best solution for your users.
0
 
BlakeMcKennaAuthor Commented:
Thank you rspahitz!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now