Solved

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

Posted on 2014-11-05
11
72 Views
Last Modified: 2014-11-17
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
Comment
Question by:BlakeMcKenna
  • 6
  • 5
11 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 40424356
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
 

Author Comment

by:BlakeMcKenna
ID: 40424435
This is a Windows App. I tried setting the Anchor property to None and that didn't have any affect.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 40424479
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
 

Author Comment

by:BlakeMcKenna
ID: 40424774
Is there a known formula and/or routine for Resizing controls when the Form size changes?
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 500 total points
ID: 40425009
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:BlakeMcKenna
ID: 40425037
I'll try and play around with it...
0
 

Author Closing Comment

by:BlakeMcKenna
ID: 40440558
I never got this to work so I'm not sure whether to delete the question or not!
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 40441353
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
 

Author Comment

by:BlakeMcKenna
ID: 40441484
I may need to rethink this functionality altogether! You did get me thinking though of some possible resolutions.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 40441604
Great!  This is definitely not a straightforward issue.  Good luck in finding the best solution for your users.
0
 

Author Comment

by:BlakeMcKenna
ID: 40447437
Thank you rspahitz!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Change data in datatable 8 30
Enable copy and pasting even when textbox is disabled 2 26
Getfiles in vb.net 28 43
Close tabpage of custom control 9 23
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now