2021/11/1

一、任务

自己设计并编写一个 Windows 应用程序,要求用到 TextBox、GroupBox、RadioButton、CheckBox、ComboBox、ListBox 控件

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Threading.Tasks;
 9 using System.Windows.Forms;
10
11 namespace students_tutorial3_2
12 {
13     public partial class add_student : Form
14     {
15         public String name;
16         public String kemu;
17         public String score;
18         public String id;
19         public String sex;
20         public String guake;
21
22         public add_student()
23         {
24             InitializeComponent();
25         }
26         private void add_Click(object sender, EventArgs e)
27         {
28
29             /*string[] subject = new[]{ "高数", "线性代数", "离散数学",
30                    "数据结构", "概率论", "马克思原理",
31                    "数据库原理" };
32             comboBox1.DataSource = subject;*/
33             kemu = comboBox1.Text;
34             listStu.name2 = name;
35             listStu.id2 = id;
36             listStu.sex2 = sex;
37             listStu.guake2 = guake;
38             listStu.kemu2 = kemu;
39            
40             listStu tc = new listStu();
41             tc.Show();
42
43
44         }
45
46         private void text_name_TextChanged(object sender, EventArgs e)
47         {
48             name = text_name.Text.ToString();
49         }
50
51         private void text_sid_TextChanged(object sender, EventArgs e)
52         {
53             id = text_sid.Text.ToString();
54         }
55
56         private void groupBox1_Enter(object sender, EventArgs e)
57         {
58             sex = (String)(this.radioButton1.Checked ? "女" : "男");
59         }
60
61         private void checkBox1_CheckedChanged(object sender, EventArgs e)
62         {
63             bool b1 = checkBox1.Checked;
64
65
66             if (b1)
67             {
68                 guake = "是";
69             }
70             else
71             {
72                 guake = "否";
73             }
74            
75         }
76
77         private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
78         {
79             string[] subject = new[]{ "高数", "线性代数", "离散数学",
80                    "数据结构", "概率论", "马克思原理",
81                    "数据库原理" };
82             comboBox1.DataSource = subject;
83             kemu = comboBox1.Text;
84         }
85
86         private void grade_TextChanged(object sender, EventArgs e)
87         {
88             score = grade.Text;
89         }
90
91     }
92 }
 
add.CS

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  1 using System;
  2 using System.Collections.Generic;
  3 using System.ComponentModel;
  4 using System.Data;
  5 using System.Drawing;
  6 using System.Linq;
  7 using System.Text;
  8 using System.Threading.Tasks;
  9 using System.Windows.Forms;
 10
 11 namespace students_tutorial3_2
 12 {
 13     public partial class listStu : Form
 14     {
 15         static public String guake2;
 16         static public String name2;
 17         static public String id2;
 18         static public String sex2;
 19        
 20         public listStu()
 21         {
 22             InitializeComponent();
 23            
 24            
 25             textBox1.Text = name2;
 26
 27             if ( guake2== "是")
 28             {
 29                 String str = name2 + " " + id2 + " " + sex2;
 30                 listBox1.Items.Add(str);
 31             }
 32             else if (guake2 == "否")
 33             {
 34                 String str = name2 + " " + id2 + " " + sex2 ;
 35                 listBox2.Items.Add(str);
 36             }
 37
 38             string msg = "";
 39             for (int i = 0; i < listBox1.SelectedItems.Count; i++)
 40             {
 41                 msg = msg + " " + listBox1.SelectedItems[i].ToString();
 42             }
 43
 44         }
 45
 46         private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 47         {
 48            // add_student a = new add_student();
 49
 50           
 51
 52         }
 53
 54         private void left_Click(object sender, EventArgs e)
 55         {
 56             int count = listBox2.SelectedItems.Count;
 57             List<string> itemValues = new List<string>();
 58             if (count != 0)
 59             {
 60                 for (int i = 0; i < count; i++)
 61                 {
 62                     itemValues.Add(listBox2.SelectedItems[i].ToString());
 63                 }
 64                 foreach (string item in itemValues)
 65                 {
 66                     listBox2.Items.Remove(item);
 67                     listBox1.Items.Add(item);
 68                    
 69
 70                 }
 71             }
 72             else
 73             {
 74                 MessageBox.Show("请选择需要移动的人员!");
 75             }
 76
 77           
 78         }
 79
 80         private void right_Click(object sender, EventArgs e)
 81         {
 82             int count = listBox1.SelectedItems.Count;
 83             List<string> itemValues = new List<string>();
 84             if (count != 0)
 85             {
 86                 for (int i = 0; i < count; i++)
 87                 {
 88                     itemValues.Add(listBox1.SelectedItems[i].ToString());
 89                 }
 90                 foreach (string item in itemValues)
 91                 {
 92                     listBox1.Items.Remove(item);
 93                     listBox2.Items.Add(item);
 94
 95
 96                 }
 97             }
 98             else
 99             {
100                 MessageBox.Show("请选择需要移动的人员!");
101             }
102
103         }
104
105         private void textBox1_TextChanged(object sender, EventArgs e)
106         {
107
108         }
109
110        
111     }
112 }

  

posted @   小强哥in  阅读(80)  评论(0编辑  收藏  举报
编辑推荐:
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· 一次Java后端服务间歇性响应慢的问题排查记录
· dotnet 源代码生成器分析器入门
阅读排行:
· ThreeJs-16智慧城市项目(重磅以及未来发展ai)
· .NET 原生驾驭 AI 新基建实战系列(一):向量数据库的应用与畅想
· Ai满嘴顺口溜,想考研?浪费我几个小时
· Browser-use 详细介绍&使用文档
· 软件产品开发中常见的10个问题及处理方法
点击右上角即可分享
微信分享提示