Function implementation:
Implementation Code: 1> declare related variable storage major, Course settings and related information: [csharp] string gr, msg, xy; string [] spec, cour1, cour2, cour3, cour4, cour5; 2> In the Form1 class, the self-defined function bool checkGR () Checks student information: [csharp] private bool checkGR () {bool check = true; if (textBox1.Text. trim () = "" | textBox2.Text. trim () = "") {check = false; MessageBox. show ("name and age required");} return check;} 3> In the Form1 class, use the custom function string record () to collect student information: [csharp] private string record () {gr = ""; Gr + = textBox1.Text. trim (); if (radioButton1.Checked) gr + = ", male"; else gr + = ", female"; gr + = "," + textBox2.Text. trim () + "years old,"; string holobby = ""; foreach (Control ct1 in groupBox1.Controls) {CheckBox chk = (CheckBox) ct1; if (chk. checked = true) {holobby + = "<" + chk. text + ">" ;}}if (holobby! = "") {Holobby = "specialty" + holobby;} gr + = holobby; gr + = ". \ n "; xy =" Major <"+ comboBox1.Text +">. \ n required courses include: "; foreach (object course in listBox1.Items) {xy + =" <"+ course. toString () + ">";} xy + = ". \ N "; if (checkedListBox1.CheckedItems. Count! = 0) {xy + = "Note:"; foreach (object intr in checkedListBox1.CheckedItems) {xy + = "<" + intr. toString () + ">"; xy + = ". ";}} Msg + = gr + xy; return msg;} 4> Load event handler code: [csharp] private void form=load (object sender, EventArgs e) {radioButton1.Checked = true; spec = new string [5] {"computer", "software", "network", "Iot", "communication"}; comboBox1.DataSource = spec; comboBox1.SelectedIndex = 0; cour1 = new string [] {"Computer Application", "Program Design", "Database", "OPP", "Network Design", "Family Planning "}; cour2 = new string [] {"Computer Application", "programming", "Database", "OPP", "Network Design", "advanced programming "}; cour3 = new string [] {"Computer Application", "programming", "wireless network security", "OPP", "protocol analysis", "Jike "}; cour4 = new string [] {"Computer Application", "programming", "Computer mathematics", "Digital Media", "Computer Network", "Computer Science "}; cour5 = new string [] {"Computer Application", "digital power", "model power", "Mathematics", "communication", "Computer Science"}; listBox1.DataSource = cour1 ;} 5> code design of the combo box: [csharp] private void combobox?selectedindexchanged (object sender, EventArgs e) {switch (comboBox1.SelectedIndex) {case 0: listBox1.DataSource = cour1; break; case 1: listBox1.DataSource = cour2; break; case 2: listBox1.DataSource = cour3; break; case 3: listBox1.DataSource = cour4; break; case 4: listBox1.DataSource = cour5; break ;}} 6> confirm the Button code: [csharp] private void button#click (object sender, EventArgs e) {if (checkGR () {MessageBox. show (record (), textBox1.Text + "");} 7> exit the Button code: [csharp] private void button2_Click (object sender, EventArgs e) {this. close ();}