C# 导航和记忆文本框数据
该程序有一个面板,其中包含一个文本框,面板两侧各有两个按钮。C# 导航和记忆文本框数据,c#,winforms,button,textbox,navigation,C#,Winforms,Button,Textbox,Navigation,该程序有一个面板,其中包含一个文本框,面板两侧各有两个按钮。 每个按钮都充当“下一个”(>>)和“上一个”(既然你有页码,为什么不创建一个列表(或使用一个以页码为键的字典),然后在>>的按钮处理程序中,听起来不错我会试试看 public partial class Form1 : Form { Dictionary<Decimal, String> TextInfo; public Form1() { InitializeComponent(
每个按钮都充当“下一个”(>>)和“上一个”(既然你有页码,为什么不创建一个列表(或使用一个以页码为键的字典),然后在>>的按钮处理程序中,听起来不错我会试试看
public partial class Form1 : Form
{
Dictionary<Decimal, String> TextInfo;
public Form1()
{
InitializeComponent();
TextInfo= new Dictionary<Decimal, String>();
}
private void Form1_Load(object sender, EventArgs e)
{
numPage.Value = 1;
}
private void bnForward_Click(object sender, EventArgs e)
{
if (TextInfo.ContainsKey(numPage.Value))
{
TextInfo[numPage.Value] = textBox1.Text;
}
else
{
TextInfo.Add(numPage.Value, textBox1.Text);
}
numPage.Value++;
if (TextInfo.ContainsKey(numPage.Value))
{
textBox1.Text = TextInfo[numPage.Value];
}
else
{
textBox1.Text = "";
}
}
private void bnBack_Click(object sender, EventArgs e)
{
if (numPage.Value == 1)
return;
if (TextInfo.ContainsKey(numPage.Value))
{
TextInfo[numPage.Value] = textBox1.Text;
}
else
{
TextInfo.Add(numPage.Value, textBox1.Text);
}
numPage.Value--;
if (TextInfo.ContainsKey(numPage.Value))
{
textBox1.Text = TextInfo[numPage.Value];
}
else
{
textBox1.Text = "";
}
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
}
}