• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

Position button to the right (like alRight)

Hi all,

I am having a problem trying to set the position of a button to be at the right.

I'm tried:

Button.Left := PageControl1.Width - Button.Width;

but it's not on the far right but about an inch from the far right.

I cannot use Align:=AlRight because the button goes to the right BUT it expands to the height of the form too so...what can I do please?

thx

st3vo
0
ST3VO
Asked:
ST3VO
  • 3
  • 2
  • 2
  • +1
3 Solutions
 
CodedKCommented:
Change the anchor of the button top to false maybe?
0
 
ST3VOAuthor Commented:
Hmm...It's kind of worked now BUT I have no longer control on the button width.

The button is now quite big in width and I cannot change it anymore.

See code below...width is not working anymore, eventhough it's specified.

thx


Button.Anchors := [akLeft, akBottom, akRight];
Button.Width:= 22;
Button.Left := sPageControl1.Width + Button.Width;
Button.Caption:=('X');

Open in new window

0
 
FactorBCommented:
try ClientWidth instead

Button1.Width:= 22;
Button1.Top :=0; {use 0 for top right corner}
Button1.Left := Form1.ClientWidth - Button1.Width;
Button1.Caption:=('X');

Regards,
B.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
CodedKCommented:
change all anchors to false one by one and then set the width.
See which anchor gives you the problem.
Probably you need to set the anchor of right to false (set by default to true i thing).
Try it and post back.
0
 
FactorBCommented:
Sorry, change

Button1.Caption:=('X');
to
Button1.Caption:='X';
0
 
ST3VOAuthor Commented:
OK, I've tried all of them and none work 100%.

I'm not going to try: CodedK's change all anchors to false one by one and then set the width BUT the Button is created at runtime, so what's the syntax to set them to false?

0
 
AshokCommented:
Maybe like this.....

Button1.Anchors := [akLeft, akBottom, akRight];

0
 
AshokCommented:
Maybe like this.....

Button1.Anchors := [];

Remove akLeft, etc to make it false.
0
 
ST3VOAuthor Commented:
Thanks all ! It wasn't just one thing that made it work ... it was a bit of all put together :o)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now