C# coding question...

Hi folks

c# coding question for you if anyone would care to help out…

Create a form and drop a panel and a button on the form a few cm appart.
In the onclick event of the button I want the button to embed itself within the panel and take up the full size of the panel.

How do you embed a control within another control at runtime?

My background is one of Delphi - in which case you just change the parent and set the alignment.

Taking up the full size of the parent control in C# should just be a matter of setting the dock property - but how do you embed the control in the first place?

Cheers

G

can see you viewing this thread Gee, give me a couple of minutes :slight_smile:

OK, ninja update - button 2 controls button 1 in this example.

DT.

DT - thats fantastic mate.
Next DD/TPR meet I’ll gladly be buying you a pint.

erm - you’re not going to believe this but I went back to my little test program commented out the various useless invalidate and bringtofront calls that I’d been experimenting with, so that I was left with this on the button1 click

        button1.Parent = panel1;
        button1.Dock = DockStyle.Fill;

and it works fine.
Doh! I think I should have just gone to bed last night! :slight_smile:

So thanks for clarifying that mate! :wink:

glad to be of help :slight_smile:

DT.