B
Brian
Hello all,
I have an form to Enter a Name with letters from A to Z in buttons.
When you click a button, it should append the text associated with
that button to a text box.
Instead of having an EventHandler for every button with a click event
of:
private void btnA_Click(object sender, System.EventArgs e)
{
txtNameField.AppendText("A");
}
And so on...
Is there a way to shorten this, such as have just the 1 Event Handler
for all buttons? I was thinking something along the lines of this:
private void buttonLetter_Click(object sender, System.EventArgs e)
{
txtNameField.AppendText(letter);
}
private void AppendLetter(letter)
{
txtNameField.AppendText(letter);
}
I hope you realise what i'm talking about here.
I have an form to Enter a Name with letters from A to Z in buttons.
When you click a button, it should append the text associated with
that button to a text box.
Instead of having an EventHandler for every button with a click event
of:
private void btnA_Click(object sender, System.EventArgs e)
{
txtNameField.AppendText("A");
}
And so on...
Is there a way to shorten this, such as have just the 1 Event Handler
for all buttons? I was thinking something along the lines of this:
private void buttonLetter_Click(object sender, System.EventArgs e)
{
txtNameField.AppendText(letter);
}
private void AppendLetter(letter)
{
txtNameField.AppendText(letter);
}
I hope you realise what i'm talking about here.