 |
|
 |
Message Automatically Removed
|
|
|
|
 |
|
 |
In essence you're having a crap time with inheriting forms and you've decided to take it out on me by giving me a 1 vote as if i'm (or my article is) to blame
thanks for that mate.
bryce
p.s. at the top of the article it says visual studio 2005.
|
|
|
|
 |
|
 |
Hello,
The problem is: You are promoting here a technology, which seems to work fine in a simple example.
But: Live is not so simple. People use this technology and sure they use them in large projects. People work for weeks on one solution and suddendly the thing crashes. Sure ist is not your responsibility that the technology does not work properly on 2008. It is the responsibility of Microsoft. They changed a lot in the designer, and not for good.
I red your article some time ago, searching how to inherit forms. It worked. So I built my application on this theory. And it worked. (Most of the times). Unfotunatelly most of the times is not good enough at all. Now I end up replacing this inheritage with different technologies. In my case inheritance of forms turned out to be the wrong way. I have to rework 180 forms. (because of the VS designer)
So a warning, that this technology should be handled with care would be appropiate. A warning that the designer could fail should be mentioned. Inheritance does not work properly in VS 2008
This is why the 1. The article could lead programmers like me into a trap
|
|
|
|
 |
|
 |
Right i see your problem, however again its not my fault -
Instead of voting 1 for the article, the correct response is to write an article of your own based on your experiences including any mechanisms you might have learn on how to overcome issues you encountered.
Especially now as your vote of 1 has been removed. The best way to inform people is to write a follow up article.
Not to punish the original article writer for something that is not his fault.
I wish you luck in fixing your problems, its never fun when these things happen.
cheers
Bryce
|
|
|
|
 |
|
 |
Yes 5 for the Video. Keep continue.
|
|
|
|
 |
|
 |
I was so "lucky" as to try my first example using a TableLayoutPanel control to inherit in a derived form. Note that this kind of container control can not be set to protected in order to be manipulated in an inherited form...
PS: The video tutorial is excellent. I hope this becomes a common practice to every article. Well done!
|
|
|
|
 |
|
 |
Hi,
Good article at a good moment. I just posted this article and was wondering if you could help me?
i have a base class inherited from a usercontrol. This base class contains a imagelist with 12 bitmaps and a datagrid, build in designtime.
Now i created 10 new classes inherited from my base class and weird as it is. the image list is copied and not inherited. changing the bitmaps in the base class doesn't change the ones in the other 10 inherited classes..
result is that i have to modify it for each of the classes. Another bad thing is that each class has his own resource file containing the bitmaps. so 75kb x 10 = 750kb. i suppose this is no inheritance like i known it in Delphi, this is copying source.
Is there a way prevent copying the bitmaps but actually inheriting?
Reading you're article i suppose i could solve this by making the imagelist private. At this moment it's protected.
Thx
Kurt
|
|
|
|
 |
|
 |
yes i suppose so - try the programming forums for your specific problem
cheers
Bryce
|
|
|
|
 |
|
 |
i did, at this moment there's no solution.
Setting to Private doesn't work... they even remain in the direved classes but cannot be deleted. Seems a bug or shortcoming to me.
greetz and thx
Kurt
|
|
|
|
 |
|
 |
Hi,
Can you please explain, how to achieve this in WPF Application?
|
|
|
|
 |
|
 |
Hi there, sorry old chap WPF isnt my thing - Josh might be a better person to talk toabout it. I have no experience in WPF
cheers
Bryce
|
|
|
|
 |
|
 |
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?
Another one...
I tried building the similar app as you demonstrated. I succeeded in inheriting the form.
I have two forms
- ParentForm
- InheritedForm
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
public partial class ParentForm : Form
{
...
private void btnDisplay_Click(object sender, EventArgs e)
{
InheritedForm form = new InheritedForm();
form.Show();
this.Hide();
}
}
And in inherited form ..
public partial class InheritedForm : WindowsApplication1.ParentForm
{
...
private void btnDisplay_Click(object sender, EventArgs e)
{
txtDisplay.Text = "You clicked Display button.";
}
}
Now the problem is each time I click on button it goes on display a new instance of Inherited form instead of printing the text ..
Where am I going wrong?? Plz help..
Thanks in advance
|
|
|
|
 |
|
 |
wait wait ... isn't there any problem of constructor?? ya each time Inherited form is called the constructor of base class must also be called ..
But it is called only once.. then where is problem??
|
|
|
|
 |
|
 |
send me your project and I'll take a look when i get time - did you also try stepping into your code?
and did you also ensure you used "override" ?
Bryce
|
|
|
|
 |
|
 |
Is 'override' keyoword necessary? Sorry I was not aware of it as I come from C++ background.
I will try once again and then mail you. But where should I mail you Sir?
Plz help me find your address.
Still there is one question in my mind...
The event handler for button is 'private'. How can 'private' method or event handler be overridden? It should be separate for inherited class,shouldn't it?
Btw, thanks for such a quick reply..
Take Care
|
|
|
|
 |
|
 |
No need to bother you now Bryce..
The 'virtual' and 'override' are working.
Thanks for advice.
And yes, Daniel also cleared my confusion about creating Inherited form instance from Parent form handler.
Thanks to you both.
Take Care
Chaitanya Joshi
|
|
|
|
 |
|
 |
Let me see...
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 ).
Daniel Rühmer
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.
Thanks Daniel.
Take Care
Chaitanya Joshi
|
|
|
|
 |
|
 |
You're welcome!
Daniel Rühmer
Application engineer for Measurement Software
|
|
|
|
 |
|
 |
"Change the "private" to "protected" save your work!"
Use 'GenerateMember' and 'Modifiers' properties of the designer instead.
|
|
|
|
 |
|
 |
always good to have an alternative - thank you
Bryce
|
|
|
|
 |
|
 |
Could provide a little more detail?
|
|
|
|
 |
|
 |
When you select a control or component in the designer view, the properties window has a section named "Design". "GenerateMember" and "Modifiers" are two of the properties in that section. The latter can be used to change the visibility (private, protected, etc.) of the selected control or component, so you don't have to change the code by hand.
|
|
|
|
 |
|
|
 |
|
 |
I agree!
Matthew MacSuga
Sr. Software Developer
Interlink Advantage
509-789-2443
|
|
|
|
 |