Tuesday, July 14, 2009

C# beginner question?

Hi,





how can I read the value of a Text field in a C# form?





I've written a beginner's program which is supposed to Console.WriteLine the value of myText .





my class is as follow:





class Program


{


static void Main(string[] args)


{





Form myForm = new Form();


myForm.Text = "Sample Form";


myForm.HelpButton = true;


myForm.Icon = new Icon(@"C:\Program Files\Handbrake\handbrakepineapple.ico")...





TextBox myText = new TextBox();


myText.Location = new Point(100, 100);





Button myButton = new Button();


myButton.Text = "Click ME!";


myButton.Location = new Point(100, 200);





myForm.Controls.Add(myButton);


myForm.Controls.Add(myText);





myButton.Click += new EventHandler(myButton_Click);





myForm.ShowDialog();





}





static void myButton_Click(object sender, EventArgs e)


{


Console.WriteLine( The value of myText );


}


}








Thanks,





-D

C# beginner question?
It's easy:


Console.WriteLine(myText.Text);

online florist

No comments:

Post a Comment