【发布时间】:2014-11-18 14:11:09
【问题描述】:
我正在发布关于 TextBox_TextChanged 事件的确认对话框。 如果用户点击“否”,我想以某种方式将文本框恢复为其旧值(即在更改之前) 但是在触发事件时, TextBox.Text 已经是更改后的值... 有没有办法保存或恢复旧值?
欣赏任何想法或方法。谢谢!
这是我的代码:
private void txtFCServerURL_TextChanged(object sender, EventArgs e)
{
DialogResult clearGrid = MessageBox.Show("Changing the text will clear the grid. Are you sure?", "Confirmation", MessageBoxButtons.YesNo);
if (clearGrid == DialogResult.Yes)
{
for (int i = 0; i < dgvGrid.Rows.Count; i++)
{
dgvGrid.Rows.RemoveAt(0);
}
}
else txtFCServerURL.Text = [TEXT BEFORE CHANGE]
}
【问题讨论】:
-
使用 Enter 事件将 Text 属性的值存储在变量中。
-
@eranfu 我已经给你答案了。你应该接受它
-
是的,我花了一些时间来测试它。坦克!
标签: c# textbox textchanged