public Test(string GradeId, string ClassId, string activityId, int index) { InitializeComponent(); Init(); List <Student> students = dbUtill.GetCheckerListByClassIdOnTest(ClassId, activityId); int i = dbUtill.GetCountByClassIdOnTest(ClassId, activityId); string gradeName = dbUtill.getGradeNameByGradeId(GradeId); string className = dbUtill.getClassNameByClassId(ClassId); stnPanel.ItemsSource = students; int count = stnPanel.Items.Count; if (count > 0) { if (index > 0 && index < count) { stnPanel.SelectedIndex = index; } else { stnPanel.SelectedIndex = 0; } } PortConfig.serialPort1.DataReceived += new SerialDataReceivedEventHandler(Com_DataReceived); display_class.Text = " " + gradeName + className + " " + "待检测学生"; ItemCount = stnPanel.Items.Count; }