|
-
June 8th, 2011, 02:05 PM
#1
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
-
June 8th, 2011, 02:36 PM
#2
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?
-
June 9th, 2011, 02:21 AM
#3
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.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|