I did a lot of searching but nothing really helped me... so here's the problem: I need an additional Property like
public int FormResult()
{
get{ ....
The thing is I'm calling the Forms via
Form f1 = new Forms.Form2();
f1.Show;
.....
So I cannot just put the property inside the form since I could only access it then if I used
Form2 f1 = new Forms.Form2();
What I'd need is to extend the whole Form class by that property (or maybe u have a better idea..?) I first thought of the normal Class extension but that couldn't access the Resultvariable inside the class. Then I thought I'd just create a new class inheriting from Form and add that property...as one would normally do. Then I'd just use that class on all my forms and it should work - but this is where VS tells me I have inconsistent access and that lets say clsExtForm is less accessable than Form2.
This looked like this:
class clsExtForm : Form
{
private int result;
Public int FormResult()
{
Get{ return result; }
Set{ result = value; }
}
}
Then I would have used
ClsExtForm f1 = new Forms.Form2();
and changed Form2 to
public partial class Form2 : clsExtForm
That gave the above error...
Solved - all I was missing was "public" before "class clsExtForm" and they had the right accessabili开发者_C百科ty level....sorry...early in the morning here in Germany :) Any reasons why this way of doing it shouldn't be ok?
I'm looking forward to your answers! Thanks for any help!
Greetings,
Lorenz
精彩评论