Button1









How do I use Button1
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: frmCapNhat.cs Copy
25         private void button1_Click(object sender, EventArgs e)
26         {
27
28         }
File name: frmCapNhat.cs Copy
183         private void button1_Click_1(object sender, EventArgs e)
184         {
185             try
186             {
187                 string sCauA = textBox1.Text;
188                 string sCauB = textBox2.Text;
189                 string sCauC = textBox3.Text;
190                 string sCauD = textBox4.Text;
191                 string sMaCH = textBox5.Text;
192                 string sCauHoi = richTextBox1.Text;
193                 string sCauDung = "";
194                 string sCauDungLuu = "";
195                 string sTrinhDo = comboBox1.Text;
196                 if (richTextBox1.Text.ToString().Trim() == "" || textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == false && checkBox4.Checked == false))
197                 {
198                     MessageBox.Show("Bạn đã sai làm thao tác", "Thông báo");
199                 }
200                 else
201                 {
202                     if (checkBox1.Checked == true)
203                     {
204                         sCauDung = "A";
205                         sCauDungLuu += sCauDung;
206                     }
207                     if (checkBox2.Checked == true)
208                     {
209                         sCauDung = "B";
210                         sCauDungLuu += sCauDung;
211                     }
212                     if (checkBox3.Checked == true)
213                     {
214                         sCauDung = "C";
215                         sCauDungLuu += sCauDung;
216                     }
217                     if (checkBox4.Checked == true)
218                     {
219                         sCauDung = "D";
220                         sCauDungLuu += sCauDung;
221                     }
222
223                     sqlcmd = new SqlCommand("update dapan set A='" + sCauA + "',B='" + sCauB + "',C='" + sCauC + "',D='" + sCauD + "',dapan='" + sCauDungLuu + "' where mach='" + sMaCH + "'", sqlcon);
224                     sqlcmd.ExecuteNonQuery();
225                     sqlcmd = new SqlCommand("update cauhoi set cauhoi='" + sCauHoi + "', trinhdo='" + sTrinhDo + "' where mach='" + sMaCH + "'", sqlcon);
226                     sqlcmd.ExecuteNonQuery();
227                     LoadDataToListView();
228                     Bandau();
229                 }
230             }
231
232             catch
233             {
234                 MessageBox.Show("Bạn đã sai làm thao tác", "Thông báo");
235             }
236         }
File name: frmKetQua.cs Copy
63         private void button1_Click(object sender, EventArgs e)
64         {
65             this.Close();
66
67         }
File name: frmLogin.cs Copy
27         private void btThoat_Click(object sender, EventArgs e)
28         {
29             if (MessageBox.Show("Bạn có muốn thoát hay không ", "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.OK)
30             {
31                 this.Close();
32             }
33         }
File name: frmMain.cs Copy
41         private void button1_Click(object sender, EventArgs e)
42         {
43             if (MessageBox.Show("Bạn có chắc chắn muốn thoát ?","Thông báo",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
44
45             {
46                 Application.Exit();
47
48             }
49         }
File name: frmQuanLy_Admin.cs Copy
19         private void button1_Click(object sender, EventArgs e)
20         {
21             frmCapNhat CN = new frmCapNhat();
22             CN.Show();
23         }
File name: frmReg.cs Copy
43         private void button1_Click(object sender, EventArgs e)
44         {
45             if (txt1.Text == "" || txt2.Text == "" || txt6.Text == "")
46             {
47                 MessageBox.Show("Bạn phải nhập giá trị vào các ô có dấu *");
48             }
49             else
50             {
51                 string TenDangNhap = txt1.Text;
52                 string MatKhau = txt2.Text;
53                 string HoVaTen = txt3.Text;
54                 string NgaySinh = txt4.Text;
55                 string NoiSinh = txt5.Text;
56                 string SoDienThoai = txt6.Text;
57
58                 string strSQL = "insert THISINH values('" + TenDangNhap + "','" + MatKhau + "','" + HoVaTen + "','" + NgaySinh + "','" + NoiSinh + "','" + SoDienThoai + "')";
59                 SqlCommand ObjCmd = new SqlCommand(strSQL, ObjCon);
60                 ObjCmd.ExecuteNonQuery();
61                 MessageBox.Show("Bạn đã đăng ký thành công");
62                 this.Close();
63             }
64         }
File name: frmThi.cs Copy
244         private void button1_Click(object sender, EventArgs e)
245         {
246             getdatakq();
247         }
File name: Lichsuthi.cs Copy
155         private void button1_Click(object sender, EventArgs e)
156         {
157             if (rdb1.Checked==true)
158             {
159
160                 timkiemtheongay();
161             }
162             else if (rdbt2.Checked==true)
163             {
164                 timkiemtheodiemcaoanhat();
165                 tbngaythang.Enabled = false;
166
167             }
168             else if (rdbt3.Checked == true)
169             {
170                 timkiemtheodiemthapnhat();
171                 tbngaythang.Enabled = false;
172             }
173             else if (rdb4.Checked==true)
174             {
175                 loadtatca();
176                 tbngaythang.Enabled = false;
177             }
178             else
179             {
180                 MessageBox.Show("Bạn hãy chọn một cách tìm");
181             }
182         }
File name: Form1.cs Copy
58   public void Button1_Click(System.Object sender, System.EventArgs e)
59   {
60    int a = default(int);
61    decimal b = new decimal();
62
63    if (Information.IsNumeric(TextBox3.Text))
64    {
65     if (int.Parse(TextBox3.Text) <= 20 )
66     {
67      a = (int) ((double.Parse(TextBox3.Text) * 100) / 20);
68      TextBox4.Text = a.ToString();
69      b = (decimal) (a * 0.1);
70      TextBox5.Text = b.ToString();
71     }
72     else
73     {
74      MessageBox.Show("Please Enter value equal to 20 and below!");
75     }
76    }
77    if (Information.IsNumeric(TextBox6.Text))
78    {
79
80     if (int.Parse(TextBox6.Text) <= 50 )
81     {
82      int c = default(int);
83      decimal d = new decimal();
84      c = (int) ((double.Parse(TextBox6.Text) * 100) / 50);
85      TextBox7.Text = c.ToString();
86      d = (decimal) (c * 0.1);
87      TextBox8.Text = d.ToString();
88
89     }
90     else
91     {
92      MessageBox.Show("Please Enter value equal to 50 and below!");
93
94
95     }
96    }
97
98    if (Information.IsNumeric(TextBox9.Text))
99    {
100     if (int.Parse(TextBox9.Text) <= 50 )
101     {
102      int g = default(int);
103      decimal f = new decimal();
104      g = (int) ((double.Parse(TextBox9.Text) * 100) / 50);
105      TextBox10.Text = g.ToString();
106      f = (decimal) (g * 0.2);
107      TextBox11.Text = f.ToString();
108
109     }
110     else
111     {
112      MessageBox.Show("Please Enter value equal to 50 and below!");
113
114
115     }
116    }
117    if (Information.IsNumeric(TextBox12.Text))
118    {
119     if (int.Parse(TextBox12.Text) <= 100 )
120     {
121      int g = default(int);
122      decimal f = new decimal();
123      g = (int) ((double.Parse(TextBox12.Text) * 100) / 100);
124      TextBox13.Text = g.ToString();
125      f = (decimal) (g * 0.3);
126      TextBox14.Text = f.ToString();
127
128     }
129     else
130     {
131      MessageBox.Show("Please Enter value equal to 100 and below!");
132
133
134     }
135    }
136
137    if (Information.IsNumeric(TextBox15.Text))
138    {
139     if (int.Parse(TextBox15.Text) <= 100 )
140     {
141      int j = default(int);
142      decimal f1 = new decimal();
143      j = (int) ((double.Parse(TextBox15.Text) * 100) / 100);
144      TextBox16.Text = j.ToString();
145      f1 = (decimal) (j * 0.3);
146      TextBox17.Text = f1.ToString();
147
148     }
149     else
150     {
151      MessageBox.Show("Please Enter value equal to 100 and below!");
152
153
154     }
155    }
156
157    decimal adal = new decimal();
158    adal = (decimal) (Conversion.Val(TextBox5.Text) + Conversion.Val(TextBox8.Text) + Conversion.Val(TextBox11.Text) + Conversion.Val(TextBox14.Text) + Conversion.Val(TextBox17.Text));
159
160    TextBox18.Text = adal.ToString();
161
162    if (Conversion.Val(TextBox18.Text) <= 74)
163    {
164
165     TextBox19.Text = "Failed";
166     TextBox19.ForeColor = Color.Red;
167    }
168    else
169    {
170     TextBox19.Text = "Passed";
171     TextBox19.ForeColor = Color.Black;
172
173
174    }
175
176
177   }

Button1 173 lượt xem

Gõ tìm kiếm nhanh...