C# Form inheritance with new controls
HI guys
I have a main form and created a class that inherits from the main form :
namespace ClientServices
{
class ControllerClass : ClientServices
{
}
}
What happens now is that the ControllerClass looks like the ClientService!
The Problem that I have is that now that I add New controls to the ControllerClass (Via the toolbox) they show but as soon as I compile the application they disappear! Even when you stop the compilation they are gone but the code is still there?
Can anyone please advice?
Thanks
Re: C# Form inheritance with new controls
for example :
namespace ClientServices
{
class ControllerClass : ClientServices
{
public void AddButton()
{
Button btn = new Button();
btn.Text = "New Button";
btn.Location = new Point(100, 100);
panel1.Controls.Add(btn);
}
}
}
and then my :
private void TrVHIMenue_AfterSelect(object sender, TreeViewEventArgs e)
{
ControllerClass c = new ControllerClass();
c.AddButton();
}
CAN ANYONE HELP?
Re: C# Form inheritance with new controls
Visual inheritance was allways trouble in VisualStudio, so I would prefere composition of user controls over inheritance. But if you really need it, check the z-order of the controls in the designer, and if you want to put the control into a panel from the ancestor, be sure that the modifier of the panel is protected.