I have an issue where two text labels are on the same horizontal line on a form.
The label to the left expands to the right and down and is anchored to the bottom left of the form.
The label on the right is anchored to the bottom right of the form.

Both labels hold an address, one is a mailing address, the other is a physical address.

Both should have left aligned text, but the problem is that since the labels are autosized to fit their content, the label on the right always runs off the screen and when the form is resized, because of the anchor, nothing changes.

Is there a way to do something like this: (ASCII art is hard!)

------------------------------------------------------------------------
|                                                                       |
|  123 Any Street                                 2039 Market Street    |
|  Cincinnati, OH 45168                           Cincinnati, OH 45168  |
|                                                                       |
------------------------------------------------------------------------

instead of:

------------------------------------------------------------------------
|                                                                       |
|  123 Any Street                                       2039 Market Stre|
|  Cincinnati, OH 45168                                 Cincinnati, OH 4|
|                                                                       |
------------------------------------------------------------------------

I'd really appreciate any advice!

Did you tried to use only AnchorStyles.Right for those 2 labels?

BR

Add a variable to your form

labelRightEdge = myLabel.Location.X + myLabel.Size.Width;

Then add either a Layout, Resize or SizeChanged event handler to your label. Doesn't matter which one, they all are fired when the label needs to change size. Put this in the handler:

Point p = myLabel.Location;
            p.X = labelRightEdge - label1.Size.Width;
            myLabel.Location = p;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.