【发布时间】:2017-08-17 07:02:31
【问题描述】:
我在两个单独的表单中有两个列表框一旦填写了一个并使用了按钮单击事件,我希望在这种情况下来自该列表框的数据将一堆分数传输到另一个表单。到目前为止,我的问题是将第二种形式的列表框转换为数组列表。
代码如下:
表格1
Form3 newForm1 = new Form3(this);
newForm1.ShowDialog();
foreach (string s in newForm1.updateStudentInfo)
{
listForm1.Items.Add(s);
}
表格2:
public List<string> updateStudentInfo { get; set; }
string student = txtName.Text;
string[] stuffFromList = listboxscores // Unsure how to transfer into an arraylist
for (int i = 0; i < stuffFromList.Length; i++)
{
student = student + "|" + form3.listForm1.Items.Add(stuffFromList[i]);
}
updateStudentInfo.Add(student);
form3.listForm1.Items.RemoveAt(form3.listForm1.SelectedIndex);
this.Close();
}
【问题讨论】:
-
抱歉,如有任何混淆,我的主表格中的学生看起来像这样 Jame|22|45|66 当我们按下更新时,它会移动到另一个带有名称文本框的表格,学生的分数在列表框。一旦他们被编辑,我按下 OK 按钮,目前它只将名称转移回来,我也需要得分。