Finding controls from an event handler
Suppose I create a System.Windows.Form object within a function, and place a textbox and button on it. I then add a function to handle a click event for the button. How can I get access to the textbox from the event handler without declaring a class-wide variable? Ie:
Note that I do not want to make a new class for the form.
static void Main()
Form form=new Form();
TextBox text=new TextBox();
Button button=new Button();
private void ButtonClick(object sender, EventArgs e)
//How do I get access to "text" here?
How can I safely access the "text" object?