您好我創建了學生和檔次的數組我的問題是 我如何使它所以如果我從指數0選擇學生山姆和展示自己的成績的下拉框裏面的第一陣列。我要寫什麼代碼才能將它們結合在一起。如果你能幫助我,我會非常感激。組合框陣列選擇顯示
private void Form1_Load(object sender, EventArgs e)
{
string[] student = { "Sam", "Dean", "Nick", "Shara", "Kat" };
cboStudent.Items.AddRange(student);
cboStudent.SelectedIndex = 0;
string[] S1Grade = { "Math: 78", "English: 56", "Bio: 94", "Art: 67", "Science: 64", "PE: 85", "Social: 89" };
cboGrades.Items.AddRange(S1Grade);
string[] S2Grade = { "Math: 45", "English: 84", "Bio: 56", "Art: 67", "Science: 78", "PE: 45", "Social: 76" };
cboGrades.Items.AddRange(S2Grade);
string[] S3Grade = { "Math: 68", "English: 34", "Bio: 98", "Art: 56", "Science: 55", "PE: 65", "Social: 56" };
cboGrades.Items.AddRange(S3Grade);
string[] S4Grade = { "Math: 38", "English: 78", "Bio: 76", "Art: 67", "Science: 34", "PE: 45", "Social: 56" };
cboGrades.Items.AddRange(S4Grade);
string[] S5Grade = { "Math: 88", "English: 84", "Bio: 56", "Art: 45", "Science: 56", "PE: 85", "Social: 89" };
cboGrades.Items.AddRange(S5Grade);
}
private void button1_Click(object sender, EventArgs e)
{
string selectedStudent = cboStudent.Text;
txtSelected.Text = selectedStudent;
}
private void cboGrades_SelectedIndexChanged(object sender, EventArgs e)
{
string selectedGrade = cboGrades.Text;
}
你可能會更好做了'Student'類和創造他們的名字和等級屬性。 –
我有兩個組合框,當我選擇一個學生時,有沒有第二個組合框顯示他們評分的數組的方法? – TheBoringGuy
沒人能幫助我嗎? – TheBoringGuy