Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 导航和记忆文本框数据_C#_Winforms_Button_Textbox_Navigation - Fatal编程技术网

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)
    {

    }




}