Sorry for the noob question...I would like to output the contents of the TextBox to the console every time a button is clicked. My TextBox variable, "textBox," is not being seen because I assume it is out of scope. I'm wondering what the correct way to go about this is.
Thank you.
class Test : Form
{
public Test()
{
Button btn = new Button();
btn.Text = "Click Me";
btn.Parent = this;
btn.Location = new Point(100, 10);
btn.Click += ButtonOnClick;
TextBox textBox = new TextBox();
textBox.Parent = this;
textBox.Size = new Size(150, 25);
textBox.Location = new Point(60, 60);
}
void ButtonOnClick(object objSrc, EventArgs args)
{
String message = textBox.Text;
Console.WriteLine(message);
}
}
class Driver
{
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Test());
}
}
}