Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread Keep labels and edit controls on on same line in responsive design
Sat, Jan 20 2018 12:19 PMPermanent Link

Anthony

I've got a form with labels followed by edit controls such as edit, combobox and checkboxe. I have set the layout options to consumption right, overflow bottom and position topleft. This works well on most screen sizes but on mobile I sometimes get the label on the line above the edit control.

Is there a way to keep the label with the associated edit control for all screen sizes?
Sun, Jan 21 2018 3:20 AMPermanent Link

Uli Becker

Anthony,

> Is there a way to keep the label with the associated edit control for all screen sizes?

You need a container control for both controls, e.g. a TBasicPanel with
a transparent background.

Uli

Mon, Jan 22 2018 3:44 AMPermanent Link

Matthew Jones

Uli Becker wrote:

> a TBasicPanel with a transparent background.

Indeed, and the new auto-sizing helps a lot, as you can auto-size the label, fix the edit control, and know that it won't take more than it ever needs. Works well.

--

Matthew Jones
Tue, Jan 23 2018 2:52 AMPermanent Link

Anthony

Thanks Uli and Matthew

I have added each label and edit controls to a basic panel and set the auto sizing and they stay on the same line on all screen sizes.

However the right side of the controls are not aligned, I tried to change the stretch right property at runtime in the forms onshow and onsize event for form widths of less than 400 but am getting runtime errors I assume due to creation order, if I run the same code from a button it right aligns the components.
Tue, Jan 23 2018 3:50 AMPermanent Link

Matthew Jones

Anthony wrote:

> However the right side of the controls are not aligned

You can do some manual sizing of the labels and edits to make them all the same size. I suspect that stretching will cause trouble if you are wanting the overflow to work too.

--

Matthew Jones
Tue, Jan 23 2018 5:07 AMPermanent Link

Uli Becker

Anthony,

> However the right side of the controls are not aligned, I tried to change the stretch right property at runtime in the forms onshow and onsize event for form widths of less than 400 but am getting runtime errors I assume due to creation order, if I run the same code from a button it right aligns the components.

You would have to show some code to get help with this.

Uli
Tue, Jan 23 2018 9:43 AMPermanent Link

Anthony

Uli Becker wrote:

> You would have to show some code to get help with this.

I create the form and show the form with

  Form2:=TForm2.Create(nil);
  Form2.ShowModal;

In the onSize event of form2 I  have

if Form2.width < 400 then
begin
 with MultiLineEdit1 do
 begin
  Layout.Consumption := lcRight;
  Layout.Overflow := loBottom;
  Layout.Position := lpTopLeft;
  Layout.Stretch := LsBottomRight;
end;

The error message I get is "Unable to get property 'tcontrol_getwidth' of undefined or null reference

If I autocreate this form I don't get the error but the controls don't resize.

If I remove the onsize event and execute the same code from a button on form2 the controls resize correctly.
Tue, Jan 23 2018 12:01 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Anthony,

<< The error message I get is "Unable to get property 'tcontrol_getwidth' of undefined or null reference >>

Try removing the Form2 reference in the OnSize event.  If the OnSize is getting triggered during the creation of the form, then the Form2 variable will not be set yet, so it will be nil.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Jan 23 2018 12:40 PMPermanent Link

Anthony

Tim Young [Elevate Software] wrote:

>Try removing the Form2 reference in the OnSize event.  If the OnSize is getting triggered during the creation of the form, then the Form2 variable will not be set yet, so it will be nil.

Hi Tim, if I remove Form2 the reference and use just if width < 400 then I get the same error.
Wed, Jan 24 2018 4:29 AMPermanent Link

Matthew Jones

Anthony wrote:

>  if I remove Form2 the reference and use just if width < 400 then I get the same error.

I'd not expect that to fail - have a look in the Chrome debugger and see what is actually happening.

--

Matthew Jones
Page 1 of 2Next Page
Jump to Page:  1 2
Image