i am not able to change the background color of mdi form?

Posted by Sudheep.grandhe under C# on 11/3/2011 | Points: 10 | Views : 7300 | Status : [Member] | Replies : 3
Hi,

i am not able to change the background color of mdi form?

private void Welcome_Load(object sender, EventArgs e)
{
//MdiClient ctlmdi;
foreach (Control control in this .Controls )
{
MdiClient client = control as MdiClient;
if (!(client == null))
{
client.BackColor = Color.Aquamarine;
break;
}
}


//try
//{
// ctlmdi = (MdiClient)ctl;
// ctlmdi.BackColor = this.BackColor;
//}
//catch (InvalidCastException exc)
//{
// //catch and ignore the error if casting failed
//}

HomePage hp = new HomePage();
hp.MdiParent = this;
hp.Show();
}

Best,
Sudheep.



Responses

Posted by: Naraayanan on: 2/14/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
try this
      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 = Color.Yellow;
}
catch (InvalidCastException exc)
{
// Catch and ignore the error if casting failed.
}
}
}


Check this link
http://www.codeproject.com/Tips/58477/Change-Back-Color-of-MDI-Parent-form-on-its-load


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 2/14/2012 [Member] Silver | Points: 25
Posted by: Sksamantaray on: 2/14/2012 [Member] Silver | Points: 25

Up
0
Down
http://support.microsoft.com/kb/319465
http://support.microsoft.com/kb/319417

Also look into these links

Thanks,
Sanjay

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response