473,781 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Label Expand Left

I have two labels on a form. The text for these two labels is assigned at
runtime.

lblLeft lblRight

If the text for lblLeft is wider than the default, the text runs into
lblRight.

How do I make lblLeft automatically expand to the left?

Thanks,
Randy
Nov 29 '07 #1
4 6544
Hi,

I'm not sure if this is doable, first take a look at Label.RightToLe ft.
Otherwise you will have to calculate the position of label 2. using
Label.Width (or Graphics.Measur eString) you can determine the width lf
lblLeft and then position lblRight accordingly.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"randy1200" <ra*******@disc ussions.microso ft.comwrote in message
news:8D******** *************** ***********@mic rosoft.com...
>I have two labels on a form. The text for these two labels is assigned at
runtime.

lblLeft lblRight

If the text for lblLeft is wider than the default, the text runs into
lblRight.

How do I make lblLeft automatically expand to the left?

Thanks,
Randy

Nov 29 '07 #2
On 2007-11-29 11:37:01 -0800, randy1200
<ra*******@disc ussions.microso ft.comsaid:
I have two labels on a form. The text for these two labels is assigned at
runtime.

lblLeft lblRight

If the text for lblLeft is wider than the default, the text runs into
lblRight.

How do I make lblLeft automatically expand to the left?
It depends on what behavior exactly you need.

But one solution would be to set the left label to be right-aligned
text, and then position the two controls so that they are flush against
each other (right edge of left label against left edge of right label).
Then the left label's text will always be positioned starting far
enough at the left to always just reach the right label's text.

If you want something more complicated, then you will probably have to
write some code to explicitly position the left label based on its
width, as Igancio suggests.

You _might_ be able to do something by creating a UserControl that
contains your two labels and is the same size as whatever area within
your form you want those two labels to occupy at most, and then doing
something with the Anchor and Dock properties of the labels so that the
left label always fills whatever space is remaining according to your
needs. But I haven't given that much thought, have never tried it
myself, and it could be a wild goose chase trying to do it that way. :)

Pete

Nov 29 '07 #3
Assuming you don't want to add custom code and that this is a regular
windows form, you may want to take a look at the "TableLayoutPan el control".
You can configure that thing so that the label wraps in multiple line if it
does not fit on the table cell or make the cell grow with the label pushing
the label on the right without overlapping.

Not sure if this would do what you want but you may want to give it a shoot.
Nov 29 '07 #4
Many thanks for all the responses.

I tried the suggestions on setting Properties such as right to left and
TextAlign, but when the label text was reassigned at runtime, the text did
not expand to the left as I had hoped.

Measuring the new text lengh and repositioning seems like a viable solution.

The tableLayoutPane l solution seemed simplier, so I went with that.

Thanks again,
Randy
"randy1200" wrote:
I have two labels on a form. The text for these two labels is assigned at
runtime.

lblLeft lblRight

If the text for lblLeft is wider than the default, the text runs into
lblRight.

How do I make lblLeft automatically expand to the left?

Thanks,
Randy
Nov 30 '07 #5

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

Similar topics

10
11459
by: Steve | last post by:
I'm not sure if I should be using tables here to structure the layout or if CSS is okay. I have a data entry form in which I have floated the labels to one side, and given them a specific width. With regular input such as textboxes, everything lines up fine. The problem I'm having is that I have an unordered list of checkboxes, and only the first item will line up with the label. The additional checkboxes and their labels end up being...
3
13158
by: TR | last post by:
Is it possible with CSS to prevent this wrapping alignment with a checkbox with a nested label? This is the label of the checkbox that wraps beneath it I'd prefer it looked like this, with a flush left margin:
7
2980
by: Jared | last post by:
Here is my situation. I have multiple labels on a form but only certain ones will become visible while using the form. Depending on which check box(s) you pick, on another form, determines the labels that appear. I have that much working as of now. What I need to know is, how do I format the labels to align underneath one and other. So when I check the first check box, the corresponding label appears and when I check the third check box...
11
11511
by: Peter Larsen [] | last post by:
Hi, I have two questions related to the Label control. How do i prevent the label from expand the canvas into 2 lines (word wrap) ?? At the moment i set AutoSize to false (to prevent the word wrap from happening) and Anchor to Left, Right (to enable the with autosize). How do i prevent a tool-tip from happening if the text is to large to fit in
0
1690
by: tweakmy | last post by:
Hi to all expert, ladies coders and gentlemen coders, I m quite newbie in this. I just started vb.net not long ago..because i was too crazy bout making an application for my own phone. as for now, i m using .net compact framework to code for my wm6. My program is easy. the purpose is to edit a .ini file by pointing the correct program path for each line .in the ini file. in my program, a treeview is enabled. By selecting on the treenode, this...
4
4561
by: skanemupp | last post by:
using python And tkinter. i have a GUI that outputs a text among other things. after input form user i want this text to be *)cleared and/or *)overwritten. what is the best way to achieve that? also, how do i make Label-text expand to the right and not to the left?
2
2456
by: shapper | last post by:
Hello, I am styling the labels on a section of my page as follows: label {float: left; width: 6.5em;} Now I want to remove this styling from a label that has the class "Message". Mu questions are:
6
12822
by: AJM Project | last post by:
Hello, I see this is a well known thing and have seen many answers but none have worked for me. It's just a test page I'm making and I've ran into this so I thought I'd ask how to fix it - inline & embedded CSS just now as It's just a quick test page I'm working on. Basically I've got my container div, two other div columns inside with fixed widths. In the 2nd column I have 2 divs, one is under the other, which exceeds the size of the...
9
8028
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have a MDI Container Form, with one label control on the Background of this container form. When I now open a child form, this form is behind the label ... and this looks ugly ... :-)) When I set the label with "SendToBack", it completely disapears. I also tried to set the child form like "BringToFront" but this also does not help.
0
9474
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,...
0
10308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10076
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
9939
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8964
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
7486
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
6729
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
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2870
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.