2010-03-30 11 views

Répondre

1

Peut-être que cela aidera? http://support.microsoft.com/kb/319465

+0

Je l'ai fait. cela ne fonctionne pas –

+0

Vous configurez votre parent MDI et les enfants avant ou après l'événement Load du formulaire se produit. Lorsque vous déboguez, pouvez-vous vérifier qu'il existe un contrôle de type MdiClient? Plus de détails sur le comportement seraient utiles. – jpierson

0

Si vous faites une couleur simple essayez le code ci-dessous, si vous essayez de définir une image, vous pouvez utiliser BackgroundImage avec BackgroundImageLayout

MdiClient ctlMDI; 
      foreach (Control ctl in this.Controls) 
      { 
       try 
       { 
        ctlMDI = (MdiClient)ctl; 

        // Set the BackColor of the MdiClient control. 
        ctlMDI.BackColor = Color.DarkRed; 
       } 
       catch (InvalidCastException exc) 
       { 
        // Catch and ignore the error if casting failed. 
       } 
      } 
1
Private ClientControl As MdiClient 

    Public Sub New() 
     InitializeComponent() 

     ClientControl = Nothing 
     For Each Ctl As Control In Me.Controls 
      ClientControl = TryCast(Ctl, MdiClient) 
      If ClientControl IsNot Nothing Then Exit For 
     Next 
    End Sub 

'iN FORM LOAD 

ClientControl.BackColor = Color.Cyan 
0

Essayez ceci, cela fonctionne.

foreach (Control control in this.Controls) 
{ 

    // #2 
    MdiClient client = control as MdiClient; 
    if (!(client == null)) 
    { 
     // #3 
     client.BackColor = GetYourColour(); 
     // 4# 
     break; 
    } 

}