Hi Guys ,
Can you please let me know how I can have a several undo function on a text box?
For example, I have a textBox1 and a btn.Now I would like to redo the textbox value until to back to the very first value entered by user.
I tried this way but it didn't go through!
private void btnUndo_Click(object sender, EventArgs e) {
string iniVal = txtContext.Text;
while (txtContext.Text != iniVal)
{
{
txtContext.Undo();
}
}
Thanks for your time in advance
Loading
FroglegPosted Apr 29, 2011, 6:51 PM
public partial class Form1 : Form
{
List
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void bttnAccept_Click(object sender, EventArgs e)
{
txtStr.Add(textBox1.Text);
}
private void bttnUndo_Click(object sender, EventArgs e)
{
if (txtStr.Count > 0)
{
txtStr.RemoveAt(txtStr.Count - 1);
if (txtStr.Count != 0)
{
textBox1.Text = txtStr[txtStr.Count - 1];
}
}
}
}
Behrouz HosseiniPosted Apr 30, 2011, 2:44 AM
This is exactly what I was looking for