The inherited form will definitiely inherit all the functionality that is public, won't it?
Now ... event handlers for the controls mostly buttons are also inherited?
I tried building the similar app as you demonstrated. I succeeded in inheriting the form.
I have two forms
Both contain (The inherited will definitely..) One text box & one button
Initially I had coded parent display button to display text "You clicked display" in textbox. But after modifying I changed the code like follows
publicpartialclass ParentForm : Form
privatevoid btnDisplay_Click(object sender, EventArgs e)
InheritedForm form = new InheritedForm();
You are creating an instance of InheritedForm in ParentForm. Now you do have an hen-and-egg problem, don't you? Both event handlers btnDisplay_Click are handled if you create an instance of InheritedForm and thus the text will be displayed in the hidden form, when the new instance pops up. Just remove the btnDisplay_Click handler in ParentForm and instantiate and show InheritedForm.
You must not create an instance of an inherited form in its base form (of course you can, but I have no idea why you would?), because by deriving from ParentForm you are instantiating InheritedForm. ParentForm I understand as a template for other forms, so create an instance of InheritedForm in your MainForm, which is now using ParentForm with its controls as its base and btnDisplay will work as expected (I think ).
Application engineer for Measurement Software
Wow .. now that was something that my dumb brain did not strike. Ya by doing that I am voilating OO principle of inheritance.
But, as a matter of factly it was just a test. Anyways. So it does have solution then. Fine.