views:

93

answers:

2

Hi,

I have a TGroupBox as a parent and i want to place a button inside it, and make it so the button would stick to the top right corner of groupbox.

The problem is, TGroupBox does not have the method OnResize, so i don't know how to tell a button where should it move after groupbox was resized.

Is there any way to make it happen?

Thank you

+3  A: 

Place it in correct place and change his properties Anchor.akLeft to false and Anchor.akRight to true. No need to attach to any events.

So Anchor will be:

.akTop = true
.akLeft = false
.akBottom = false
.akRight = true

(properties of button inside groupbox)

robfox
+7  A: 

Set the button's Anchors property to include akTop and akRight. When its parent's size changes, it will move to keep its top and right offsets constant relative to the edges of the parent control. The default value has akLeft instead. (If both akLeft and akRight are set, then the button's width will grow and shrink with its parent.)

Between the Align, Anchors, and Constraints properties, you will rarely have to write any of your own code to handle changes to a parent's size.

Rob Kennedy
Thank you. Such a simple thing, and i have never taken a look at this property before :)