April 14, 2014 (Monday)
namespace ZauBawk_ComboBox_LabAssignment
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string[] sNames = { "Zau", "David", "Grace", "Joe", "Mary", };
cboStudents.Items.AddRange(sNames);
cboStudents.Text = "Select a Student Name";
}
private string[] Selecting(int index)
{
string[] arr = null;
switch (index)
{
case 0: arr = new[] { "Math: 99", "Eng: 56", "BUSS: 94", "Art: 67", "CSI-152: 64", "Database: 85", "Web Graphic: 89" }; break;
case 1: arr = new[] { "Math: 99", "Eng: 84", "BUSS: 56", "Art: 67", "CSI-152: 78", "Database: 45", "Web Graphic: 76" }; break;
case 2: arr = new[] { "Math: 98", "Eng: 34", "BUSS: 98", "Art: 56", "CSI-152: 55", "Database: 65", "Web Graphic: 56" }; break;
case 3: arr = new[] { "Math: 97", "Eng: 78", "BUSS: 76", "Art: 67", "CSI-152: 34", "Database: 45", "Web Graphic: 56" }; break;
case 4: arr = new[] { "Math: 88", "Eng: 84", "BUSS: 56", "Art: 45", "CSI-152: 56", "Database: 85", "Web Graphic: 89" }; break;
default: arr = null; break;//no correct index;
}
return arr;
}
private void cboStudents_SelectedIndexChanged(object sender, EventArgs e)
{
cboGrades.Items.Clear();
cboGrades.Items.AddRange(Selecting(cboStudents.SelectedIndex));
}
}
}

No comments:
Post a Comment