Connecting Tech Pros Worldwide Forums | Help | Site Map

Make a Label Shrinkable

Sl1ver's Avatar
Member
 
Join Date: Mar 2009
Location: Cape Town, South Africa
Posts: 104
#1: Jun 12 '09
Hi guys
I've got an app and if its minimized my label will be too long therefore going over my textbox.

Question
How do i make the label so that if the program "shrinks" then the label will shorten followed by three dots
e.g Search Location
And when the app is shrunk maybe look like this
e.g Search Lo...

Any Help would be much appreciated

Expert
 
Join Date: Jun 2008
Location: Pretoria, South Africa
Posts: 410
#2: Jun 12 '09

re: Make a Label Shrinkable


Quote:

Originally Posted by Sl1ver View Post

Hi guys
I've got an app and if its minimized my label will be too long therefore going over my textbox.

When your application gets minimized no controls will be visible, all that you can see is the form title in the task bar of windows.
I don't understand how you can see textboxes and labels in a mimimized application and when the window is restored all controls will appear exactly as they did before the mimimize unless you programmed it to change the appearance of the form.
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#3: Jun 12 '09

re: Make a Label Shrinkable


If you meant they overlap when resizing, take a look at the Dock and Anchor properties.
(And if you are using .NET3.0+ I think there are auto-shrink / auto-grow properties as well)
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,783
#4: Jun 12 '09

re: Make a Label Shrinkable


Quote:

Originally Posted by Sl1ver View Post

Hi guys
I've got an app and if its minimized my label will be too long therefore going over my textbox.

Question
How do i make the label so that if the program "shrinks" then the label will shorten followed by three dots
e.g Search Location
And when the app is shrunk maybe look like this
e.g Search Lo...

Any Help would be much appreciated

Since you wouldn't be able to see the label or the text box with the app truly minimized (just a button on the Start bar) I'm going to guess that *your* minimized is a really a smaller version of the form. Kind of like mini-player view of a media playing app only has 'play,pause' instead of the full control set.
Quote:
How do i make the label so that if the program "shrinks" then the label will shorten followed by three dots
On the Resize event check the width of the form and react accordingly.

Expand|Select|Wrap|Line Numbers
  1. if (MyForm.Width < 200)
  2. {
  3.    myLable.text = myVariable.substring(0,20) + "[...]";
  4. }
  5. else  myLable.text = myVariable;
  6.  
Sl1ver's Avatar
Member
 
Join Date: Mar 2009
Location: Cape Town, South Africa
Posts: 104
#5: Jun 17 '09

re: Make a Label Shrinkable


I got a bad way of explaining stuff, you seem to understand me and give helpfull feedback. Thanx tlhintoq, much appreciated
Reply