hey,
How do I get the child form to be "on top" of the parent form?.
i.e the label on the parent form is appearing on top of the child form (see attached image), is there any code/property to change this?
thanks
Printable View
hey,
How do I get the child form to be "on top" of the parent form?.
i.e the label on the parent form is appearing on top of the child form (see attached image), is there any code/property to change this?
thanks
You can set the label's visible property to false befroe showing your child form. Then in the child form closing event, just set the visible property of the label on the parent form back to true.
yea I was thinking that,
seems a bit of a round about way of fixing this issue tho, is there no other property of setting the child form to be on top?
You need to understand how an MDI application works. When you set the IsMdiContainer property of a form to True it adds an MdiClient control to that form. The grey area you see in the client area of the form is that control. It's actually that control that hosts the child forms. That means that if you then add a control to the form it must either be in front of that MdiClient, which means it will obscure the MdiClient and any child forms it's hosting, or it must be behind it, which means it will be obscured itself. The only other option is to dock the control to an edge of the form so it will share the client area with the MdiClient. An MDI application is not intended to have controls over the child form area. If you really want text under the child forms, although I can't really see a good reason that you would, then your best option is to draw it directly on the MdiClient control, e.g.VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For Each ctl As Control In Me.Controls If TypeOf ctl Is MdiClient Then AddHandler ctl.Paint, AddressOf MdiClient_Paint End If Next End Sub Private Sub MdiClient_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) e.Graphics.DrawString("Token:", Me.Font, Brushes.Black, 25, 25) End Sub
Sorry, let's try that again in the correct language.Code:private void Form1_Load(object sender, EventArgs e)
{
foreach (Control ctl in this.Controls)
{
if (ctl is MdiClient)
{
ctl.Paint += new PaintEventHandler(MdiClient_Paint);
}
}
}
private void MdiClient_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawString("Token:", this.Font, Brushes.Black, 25, 25);
}