PDA

View Full Version : سوال: چرا برای تغییر رنگ MDI باید اینطوری کد نوشت؟



mmbguide
یک شنبه 28 دی 1393, 21:59 عصر
سلام به همه دوستان

من میخوام رنگ پس زمینه MDIWindow رو تغییر بدم ولی به این کد رسیدم و میخواستم اگه کسی میدونه توضیح بده چرا اینقدر دردسر واسه تغییر رنگ


MdiClient ctlMDI;
// Loop through all of the form's controls looking
// for the control of type MdiClient.
foreach (Control ctl in this.Controls)
{
try
{
// Attempt to cast the control to type MdiClient.
ctlMDI = (MdiClient) ctl;

// Set the BackColor of the MdiClient control.
ctlMDI.BackColor = this.BackColor;
}
catch (InvalidCastException exc)
{
// Catch and ignore the error if casting failed.
}
}

// Display a child form to show this is still an MDI application.
Form2 frm = new Form2();
frm.MdiParent = this; frm.Show();