You're right in the principle and for complex forms i used to use set/get
but here, she just want the textbox value probably a simple form dialog with
a textbox...and she wants to understand the error message.
It takes 2 seconds for convert private in public and test...more than 1
minute for implement set/get = Time x 60. Programming is a lot of consumer
of "tips".
Again, i agree with you for complex form/project but simple "things" must
stay simple.
Nicolas Guinet
"Bruce Wood" <brucewood@canada.com> a écrit dans le message de news:
1116879984.826411.26970@g14g2000cwa.googlegroups.c om...[color=blue]
> Don't expose controls outside of the form to which they belong.
>
> Instead, define public properties that allow you to get at information
> on the form, and name the property according to what it returns:
>
> public class Form1
> {
> private TextBox textbox1;
> ... etc. ...
>
> public string SalesOrderNumber
> {
> get { return this.textBox1.Text; }
> set { this.textBox1.Text = value; }
> }
> }
>
> Of course, you didn't say what "textbox1.Text" represents. I chose
> "SalesOrderNumber" just as an example, to show you that you shouldn't
> call it something like "TextBox1Text", which is pretty meaningless.
> Similarly, if you want something to happen on Form1 and that Form2 be
> able to find out when it happens, you should define an event in Form1
> that is raised whenever a button is clicked, etc, but the event is
> named sensibly, like "SalesOrderNumberChanged" or something like that.
>
> The idea is that from outside Form1, nobody cares _how_ the sales order
> number is displayed, or _how_ the user changes it. Outside callers just
> look at properties of Form1 and listen for events from Form1 in order
> to work with it.
>
> Exposing controls publicly is extremely bad practice: it exposes the
> internal workings of your form to the "outside world" and makes it much
> more difficult to change that form later.
>[/color]