I have questions about inheritance of UserControl in a WinForm project.
I have several specific panel which are different page of my application. But these specific panel have some common code repeated inside each of these panels.
So I want to code their common behaviour in a StdPanel class inherited from UserControl and then each specific pages will inherit from the StdPanel.
A specificPanel:
public partial class SpecificPanel1 : StdPanel
{
public SpecificPanel1 () : base()
{
InitializeComponent();
}
}
The StdPanel:
public partial class StdPanel: UserControl
{
public StdPanel()
{
InitializeComponent();//Keeping this line or not?
}
private void StdPanel_VisibleChanged(object sender, EventArgs e)
{
if (Visible)
{
//do stuff...
}
}
}
My questions:
My questions: I want to do things when StdPanel_VisibleChanged, I did a lot of testing and I understand that InitializeComponent() is necessary to make the StdPanel_VisibleChanged event work. At first, I wanted to remove InitializeComponent() from StdPanel because the GUI is done in a SpecificPanel1 , and I thought it was not necessary.
So does SpecificPanel1 have two GUI?
How are these two GUI nested? Are they present on the screen but one hides the second?
Thank you