2

首先我不得不说,当我的英语不太好时,所以我为我的错误和语法感到抱歉。我从许多文本框创建了简单的时间表,这些文本框位于组网格中。我有一个按钮,用于在文本框中添加一些文本。用户将在 texbox 中添加一些文本,单击按钮(创建)并创建完整的时间表,即他所需要的。还有一个问题。我可以像这样在方法 SaveState 中手动保存所有输入:e.PageState["something"] = gui_Something.Text;但是我有 3 个网格,其中有 40 个文本框...我需要某种方法将其全部保存在一种方法中,或者类似的方法。它看起来像字段,但事实并非如此。在现场我可以做类似的事情:

int[] field = new int[5];
        int some = 0;
        for (int i = 0; i < field.Length; i++)
        {
            field[i] = some;
            e.PageState["Something" + i] = gui_poznamky.Text;
        }

但我的充满文本框的网格不是字段 xD

有人能帮助我吗?我是初学者,不久前我开始编程,所以有时我需要一些帮助。感谢所有答案,再次为我的英语感到抱歉(:

4

1 回答 1

0

You could try something like this to iterate though all the controls in the grid, and then do some fancy work to find where each textboxs' data should be saved to...

foreach (Control childCtrl in MainGrid.Children)
{
    if (childCtrl is TextBox)
    {
        TextBox Txtbox = (TextBox)childCtrl;
        Console.WriteLine("Found Textbox: " + Txtbox.Name);
    }
}
于 2013-11-14T17:19:07.817 回答