Еще 2 способа К примеру, вот так:
| Код | private void button1_Click(object sender, EventArgs e) { int temp = textBox1.SelectionStart; textBox1.Text=textBox1.Text.Insert(temp, "1"); textBox1.SelectionStart = temp + 1; }
private void button2_Click(object sender, EventArgs e) { int temp = textBox1.SelectionStart; textBox1.Text = textBox1.Text.Insert(textBox1.SelectionStart, "2"); textBox1.SelectionStart = temp + 1; }
|
Это если хотите, чтобы писалось в то место, где сейчас курсор, если просто в конец, то, кроме использования textBox.Text можно еще и так -
| Код | private void button1_Click(object sender, EventArgs e) { textBox1.AppendText("1"); }
private void button2_Click(object sender, EventArgs e) { textBox1.AppendText("2"); }
|
|