Change back or background image of MDI container shape in .net

I need to change the backcolor or background image of the mdi parent in my application. I tried changing the background color or specifying a background image, this will not work. I also tried looping the controls in the form to get mdiclient and changing its inverse color, also a null result.

+3
source share
4 answers
+1
source
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
+1
source

, , , BackgroundImage 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.
                }
            }
0
source

Try it, it works.

foreach (Control control in this.Controls)
{

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

}
0
source

Source: https://habr.com/ru/post/1739087/


All Articles