Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all,

 

I'm new to C# and I'm having a problem. In VB.net I'm able to access the controls on another form (ex: a MDI child form) when I try to do the same in C#, the controls arn't listed. How would I go about accessing the controls on another form?

  • Administrators
Posted

In VB the controls are declared as public by default, C# defaults them to private.

 

You could just make the controls public but this will inevitably result in the code getting very tightly coupled to the point of changing a control on a form can break code in several other forms. A far better way would be to create public properties or methods that can be called from outside the form but will themselves change / read from the controls.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...