How to assign existing Controls to Different Parents
I have two panel controls let's say x and y.
I want to use y over x but without y being a child of x.
Is there any way to acomplish these.
Thanks.
I have two panel controls let's say x and y.
I want to use y over x but without y being a child of x.
Is there any way to acomplish these.
Thanks.
If I understand you, your problem is Y becomes inside X.
Ok, create a form, add panel X. Now add panel Y.
As you know, as soon as you move it over, it goes inside.
You can break them apart with cut and paste,
select Y.
Cut.
Click on Form.
Paste.
To move them over each other, you can just change the location prop, you could use code todo this.
Or, the code way.
this.x = new System.Windows.Forms.Panel();Remove the YELLOW code to just after GREEN code add
this
.Controls.Add(this.y);So you have
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(340, 305);
this.Controls.Add(this.x);
this.Controls.Add(this.y);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.x.ResumeLayout(false);
this.ResumeLayout(false);
Then change the location of y to match the location of x.
Why do you need todo this? there maybe better ways off doing what you want.
I think i found a way that works based on your description.
My final goal was to have e "floating" panel over onother one in a way i could toggle the visible prop of the underlying panel without afecting the "floating" one.
Based on your description i could position the panel without having it in the underlying container, then with some use of the BringToFront method i think i have what i want.
Thank you.