Durga Durga - 1 year ago 239
C# Question

Setting MdiParent Background Image properly

I am using below code to set background image of MdiParent form ,and it is working well ,but when I click on maximize button than BackgroundImage is repeating at rightside and bottom edge(i.e right side and bottom side Image portion is repeating) ,how do I avoid this and display Image properly ?

public Parent()

foreach (Control ctl in this.Controls)
if (ctl is MdiClient)
ctl.BackgroundImage = Properties.Resources.bg;
ctl.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;

Answer Source
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;

this points to Form.

Myself too noticed the same behavior you mentioned. It seems just a painting issue. Add the following code to fix it.

protected override void OnSizeChanged(EventArgs e)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download