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()
{
InitializeComponent();
foreach (Control ctl in this.Controls)
{
if (ctl is MdiClient)
{
ctl.BackgroundImage = Properties.Resources.bg;
ctl.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
break;
}
}
}
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)
{
base.OnSizeChanged(e);
this.Refresh();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With