如何将项目从文本框添加到数组? C#

时间:2012-10-23 01:10:23

标签: arrays textbox

我想将13个文本框中的项添加到数组的13个元素中。一次全部使用按钮。我该怎么做呢?

    List<double> scoreArray = new List<double>();
        TextBox[] textBoxes = { week1Box, week2Box, week3Box, week4Box, week5Box, week6Box, week7Box, week8Box, week9Box, week10Box, week11Box, week12Box, week13Box };
            for (int i = 0; i < textBoxes.Length; i++)
        {
         scoreArray.Add(Convert.ToDouble(textBoxes[i].Text));
        }

1 个答案:

答案 0 :(得分:0)

在按钮的Click事件上放置一个事件处理程序。

在处理程序中,提取文本框值并将其设置为数组的值。

轻松自在!