You have declared your form as type Form
not Form3
:
using (Form frm = new Form3())
and as the class Form
doesn't have a property ReturnValue1
you are getting the error. This compiles because Form3
is a subclass of Form
so you can assign it to a variable of type Form
without any casting being required. If you had it the other way round the compiler would have told you you needed a cast.
Your code should be:
using (Form3 frm = new Form3())
or perhaps even (my preference):
using (var frm = new Form3())
Then it will always be of the right type and you don't have to remember to change the class name in two places should you decide to use a different form in future.