Delphi – How to align the left and top control without a fixed width?

I have 6 RichEdit controls in the ScrollBox. They need to be aligned in order from top to bottom, but I need the width to be not fixed, so when the text length exceeds the ScrollBox width, I can use Scroll to view the full text.

If I set:

RichEdit1.Align := alTop;
RichEdit2.Align := alTop;
RichEdit3.Align := alTop;
RichEdit4.Align := alTop;
RichEdit5.Align := alTop;
RichEdit6.Align := alTop;

They are perfectly aligned and maintain a fixed design, so they cannot be moved accidentally, but the width is fixed. Not good.

If I align them manually, they will not be fixed when I click on them and can Move, I need to rearrange all the time. Annoying.

The picture is displayed on all RichEdits, Align = alTop and the width is fixed to the ScrollBox width.
The example below is to manually align all RichEdits, the width can exceed the ScrollBox Width, but they can be moved in the design:

enter image description here

p>

So, I want to fix them on the left, the top is the same as alTop, but don’t fix the width. How can I do this?

Use Align = alTop at design time. Then, at runtime (for example, OnCreate of the form) Set Align: = alNone, and change the width as needed.

I have 6 RichEdit controls in the ScrollBox. They need to be aligned in order from top to bottom, but I need the width to be not fixed, Therefore, when the text length exceeds the width of the ScrollBox, I can use the scroll bar to scroll to view the full text.

If I set:

RichEdit1.Align: = alTop;
RichEdit2.Align := alTop;
RichEdit3.Align := alTop;
RichEdit4.Align := alTop;
RichEdit5.Align := alTop;
RichEdit6.Align := alTop;

They are perfectly aligned and maintain a fixed design, so they cannot be moved accidentally, but the width is fixed. Not good.

If I align them manually, Then when you click on them, they will not be fixed and can be moved, I need to rearrange them all the time. Annoying.

The picture is displayed on all RichEdits, Align = alTop and the width is fixed to the ScrollBox width.
Below The example is to manually align all RichEdits, the width can exceed the width of the ScrollBox, but they can be moved in the design:

enter image description here

So, I want to fix them on the left, the top is the same as alTop, but don’t fix the width. How can I do this?

Use Align=alTop at design time. Then, set Align:=alNone at runtime (for example, OnCreate of the form), and change the width as needed.

Leave a Comment

Your email address will not be published.