ebick ebick - 1 year ago 88
Vb.net Question

How come I can't access public properties or user set controls in C# WinForms?

I grew up on VB.Net. From there, in a routine, I could instantiate a form, and access controls that I had put on that form, like a textbox. Further, after hiding the form, I could read public properties that got set on the form. I am trying to do this in C# and according to the intellisense, neither is accessible.

so, in Form 1, for example I say

Form f = new MyOtherForm();

from there, f only returns things like Text, or Tag.....I can't see any controls on f to set them.

Further, MyOtherForm has a public property called MyResult. After a show dialog, in VB.Net, I could, from the calling form, access

In C#, I cannot.

Can someone help me understand how it works in C#?

Answer Source

If you want to see the properties of MyOtherForm, you should declare the form as MyOtherForm:

MyOtherForm f = new MyOtherForm();

Beside that, you should also check if the property you are looking for is set as public.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download