Kylin
Tue Apr 05 11:12:40 CDT 2005
to solve this ,
I make a simple project,
that include two forms : Form1 ,Form2,
and I drag a TextBox and a Button into Form1,
and the Button's onclick like this :
Form2 form=new Form2();
form.label1.Text=textBox1.Text;
form.Show();
and In form2,
I drag a Label and a Button ,
public System.Windows.Forms.Label label1; //public !
private System.Windows.Forms.Button button1;
and the button's onclick here:
MessageBox.Show(label1.Text);
this is ok !
but if this code is writed in Form2's constructor
public Form2()
{
InitializeComponent();
MessageBox.Show(label1.Text);
}
Failed ! and the messagebox show that : label1
why ?
"Richard Parsons via DotNetMonster.com" <forum@DotNetMonster.com> дÈëÏûÏ¢ÐÂÎÅ:a990a809bac74270a1aa7a060a582284@DotNetMonster.com...
> There are a few ways to do this.
>
> First you could expose a public property on your main form and access that
> property from your second form.
>
> Second you can create a class that has a static (shared = vb.net) variable
> in it and set that variable from your main form and access it from your
> second form.
>
> There are other ways also but those are the quickest and least amount of
> trouble probably.
>
> Let me know if this helps or if you need help implementing either of these
> solutions.
>
> -Richard
> richard.parsons.junk@gmail.com
>
> --
> Message posted via
http://www.dotnetmonster.com