我有兩個單獨的窗體中的兩個列表框一旦填寫了一個按鈕並單擊事件,我希望來自該列表框中的數據在此實例中將一組分數傳輸到其他形式。到目前爲止,我的問題是將我的第二種形式的列表框轉換爲數組列表。如何從另一個列表框中更新列表框
下面的代碼:
Form1中
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();
}
遺憾的任何困惑我有個同學在主窗體看起來像這樣詹姆斯| 22 | 45 | 66當我們按下更新其移動到另一種形式與名稱文本框和列表框的學生的分數。一旦編輯完成,我按下確定按鈕,目前它只傳回名稱,我也需要分數。 – User3283827