473,782 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to resize label height automatically.

I am using a label as a tooltip box because I need to be able to change the
background of the box depending on the information it is representing.

That aside, I need to be able to auto-size the box depending on the amount
of data within it.

Sometimes the text in the label will be single-line, but a little long where
it needs to wrap.
Sometimes the text in the label has been forced to spread over three lines.
Sometimes the label has only one lshort text string.

The problem is that the Autosize property only affects the width of the
label, and I need it to resize to reasonable dimensions.
I do not want a very long tooltip spanning the entire screen when it could
wrap round to three shorter lines in a box.
I do not want the text in the box to become truncated because the box isn't
big enough.

So please, can anyone come up with a sensible and effective means of scaling
a label (or alternative control) so that the data within is displayed in a
box representing a 5:4 ratio or thereabouts?

Thanks in advance for any feedback. Newsgroup replies only please.

Feb 14 '06 #1
1 2432

"ngreplies" <ng*******@void tdrd.freeserve. co.uk> wrote in message
news:ds******** **@news6.svr.po l.co.uk...
I am using a label as a tooltip box because I need to be able to change the
background of the box depending on the information it is representing. The problem is that the Autosize property only affects the width of the
label, and I need it to resize to reasonable dimensions. So please, can anyone come up with a sensible and effective means of
scaling a label (or alternative control) so that the data within is
displayed in a box representing a 5:4 ratio or thereabouts?


There's probably a cleverer way these days, but when I've done things
like this I've let the Label size itself initially, then dragged it back
width-wise, kicking and screaming, until it gets to a ratio I'm happy with
- IIRC, as you "squash" it horizontally, it will grow vertically by itself.

It's probably best to do this on a non-visible Label, then copy the Text
and Size properties over to your tooltip Label (which no longer needs
to be AutoSize'd), something like

With lblAutoSizer
.Text = ...

Do While ( .Width / .Height ) > ( 5 / 4 )
.Width = CInt( .Width * 0.9 )
Loop

lblToolTip.Text = .Text
lblToolTip.Size = .Size
End With

HTH,
Phill W.
Feb 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5089
by: Curzio Basso | last post by:
Hi all, I have a problem for which I wasn't able to find an answer anywhere else, maybe someone can give me a hint... I designed with XRCed a small GUI (the code is at the bottom of the message) made up of a menu and a frame in which there are two panels, placed by an horizontal sizer. Now, what I would like to do is to be able to load an image and display
2
1863
by: Charles Packer | last post by:
From one of the online Javascript tutorials, I learned how to open a new window and set its size. I'm building a page that has several small photographs, and I want to let the viewer examine either a full size image or an image with supporting detail. It's the same idea used on lots of Web sites that show thumbnails where you click on one and the full-size image is displayed in a new window. However, I have different-sized images that will...
6
8862
by: | last post by:
Hello all, This is an IE6 question: When I click on an image file on my desktop, ie will automatically resize the image to fit the window. But, when I use html to load the image, i.e. <img src=whatever>whatever</img> the image will not resize. Can this be done ? Tia.
2
15188
by: Noah Coad [C# MCP] | last post by:
I'm creating a program the must show the time (a clock) in a user control and the text must fill the user control. How do I make text dynamically resize to fill a label/panel/usercontrol? Thanks!! -Noah Coad Microsoft MVP & MCP (.NET/C#)
3
6227
by: Poul C | last post by:
Hello With the code below I can resize all the components on a Form when ever the Form resizes. For the time beeing it dosn't allow a component to contain another component, but with a little extra work I can make it work at any dept!
1
314
by: al | last post by:
Greetings, I included a UserControl (UC)on webpage. It works fine except when I change document direction to 'rtl', UC doesn't resize with the rest of document. It just disappears behinde rest of document(textbox, labesl...etc)? Any idea/s?? Usually, what is the best way of placing UC in a webpage? In a
2
2154
by: Oenone | last post by:
I'm trying to create a form similar to a VB messagebox but with custom content. One of the things I want to be able to do is display some text in a label at the top of the messagebox form and have the form automatically expand to make room for it (which could be just a few words, or several paragraphs). In VB6 I used to use a useful trick of setting AutoSize property of the label to True, populating the Text property, setting the Width...
3
14656
by: Wenlei Fang | last post by:
Anybody knows how to accomplish this?
4
5022
by: pankajsingh5k | last post by:
Hi guys, i only know basic css mainly the formatting part.... i want to create a side panel for my website that looks like a small window that has a blue header and blue borders and slightly curved bottam border...i did this by making images and setting them as backbround images fo the respective divs here my code <div id="docket">
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8967
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.