【发布时间】:2013-01-24 14:31:02
【问题描述】:
该程序有一个面板,其中包含一个文本框,面板每侧有两个按钮。 每个按钮充当“下一个”(>>) 和“上一个”(>”导航到下一个面板,这将清除文本框。然后,当我单击“
这是我的界面图像以澄清事情:
【问题讨论】:
标签: c# winforms button textbox navigation
该程序有一个面板,其中包含一个文本框,面板每侧有两个按钮。 每个按钮充当“下一个”(>>) 和“上一个”(>”导航到下一个面板,这将清除文本框。然后,当我单击“
这是我的界面图像以澄清事情:
【问题讨论】:
标签: c# winforms button textbox navigation
既然你有页码,为什么不直接创建一个列表(或使用以页码为键的字典),然后在 >> 和
代码可能如下所示:
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)
{
}
}
【讨论】: