Reputation: 82
I set a background image in the master form then I call in the child form it's not working
I set the background image in the properties of the master form. if I put any other tool like buttons panel it working on the child form
Master Form
public partial class MasterForm: Form
{
public MasterForm()
{
InitializeComponent();
}
}
Child Form
here I call like this
public partial class item: MasterForm
{
}
Upvotes: 1
Views: 339
Reputation: 1377
BaseMasterForm .cs
public class BaseMasterForm : Form
{
// You can override this Show Background. If you want or not to show background.
public virtual bool ShowBackground { get { return true; } }
public BaseMasterForm()
{
this.Load += (s, e) =>
{
// your image
this.BackgroundImage = (ShowBackground) ? Properties.Resources.LeeQc : null;
// you can custom
this.BackgroundImageLayout = (ShowBackground) ? ImageLayout.Stretch : ImageLayout.None;
};
}
}
ChildForm.cs
public partial class ChildForm : BaseMasterForm
{
// set true or false. to show MasterForm background.
public override bool ShowBackground { get { return true; } }
public ChildForm()
{
InitializeComponent();
}
}
Upvotes: 3
Reputation: 156
I think it's not working because every page has it's own properties. You have to set the image in the MasterForm.
public partial class MasterForm: Form
{
public MasterForm()
{
InitializeComponent();
this.BackgroundImage = Properties.Resources.Image;
}
}
See here: Set the same background in all windows forms with a single setting
Upvotes: 0