How to add a custom control on TOP of another one
I'm using a winForm. I have 2 custom controls that I want to add dynamically. The first one is added at the opening of the form. The second one is added when the us开发者_JAVA百科er clicks a button. Nothing magic here. The problem is that when I instanciate and add the second control, instead of appearing on top of the other one, it appears under.
There must be a way to add the control in a way that will make it fully visible (on top of the rest). Here is how I create the second control (same way as the first control). I tried using show/hide methods, but this won't change the stack order.
private void lbRappel_Click(object sender, EventArgs e)
{
NoteCallBack noteCallBack = new NoteCallBack("test");
this.Controls.Add(noteCallBack);
noteCallBack.Location = new Point(200, 250);
}
Thank you very much in advance for your help.
Mathieu
You could try the BringToFront control function:
private void lbRappel_Click(object sender, EventArgs e)
{
NoteCallBack noteCallBack = new NoteCallBack("test");
this.Controls.Add(noteCallBack);
noteCallBack.Location = new Point(200, 250);
noteCallBack.BringToFront();
}
Can you create them at design time with the z-order you want, then only make them visible at runtime?
精彩评论