|
-
Aug 7th, 2006, 10:47 PM
#13
Re: accessing variables in the startup form from other forms
When you add a control to a form in C# the IDE creates a member variable for that control which is declared private by default, whihc is as it should be. You cannot access private members externally, as I'm sure you're aware. You can change the modifiers of the control to make it public, but that's the dodgy way. If you do that then you expose absolutely everything about that control to the outside world, including the ability for a completely different object to be assigned in it's place. The "proper" way to do it is to declare your own public properties in the form and use them as a pass-through for the control's properties. That way you expose only those properties that you specifically want to be able to access from outside. You also have the ability to make those properties read-only or write-only if that is appropriate. Of course, you know all this already because you've read part 2 of that tutorial I suggested.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|