I hope this is the place for a newbie question. If not, could someone
re-direct me please?
My problem is this:
You can put text into a textbox on a form with a simple TextBox.Text =
"Hello";
But what if you programatically draw the textbox ?
I have two buttons on a form The first draws a text box on the form. This
works fine. The second is supposed to put text into that box.
But it doesn't. I get various error messages as I try all sort of tricks to
get it to work.
EG.
Error 1 The name 'cellBox' does not exist in the current context
What am I missing ?
The code is:
private void button1_Click(object sender, EventArgs e)
{
TextBox cellBox = new TextBox();
Form1.ActiveForm.Controls.Add(cellBox);
}
private void button2_Click(object sender, EventArgs e)
{
string s = "Hello";
cellBox.Text = s;
}
Many thanks
aji