TextBox2









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

Featured Snippets


File name: frmCapNhat.cs Copy
38         private void Bandau()
39         {
40             checkBox1.Checked = false;
41             checkBox2.Checked = false;
42             checkBox3.Checked = false;
43             checkBox4.Checked = false;
44             textBox1.Text = "";
45             textBox2.Text = "";
46             textBox3.Text = "";
47             textBox4.Text = "";
48             textBox5.Text = "";
49             richTextBox1.Text = "";
50         }
File name: frmCapNhat.cs Copy
54         private void listView1_SelectedIndexChanged(object sender, EventArgs e)
55         {
56             bool bdapan = false;
57             for (int i = 0; i < listView1.Items.Count; i++)
58             {
59                 if (listView1.Items[i].Selected)
60                 {
61                     textBox5.Text = listView1.Items[i].SubItems[0].Text;
62                     textBox1.Text = listView1.Items[i].SubItems[2].Text;
63                     textBox2.Text = listView1.Items[i].SubItems[3].Text;
64                     textBox3.Text = listView1.Items[i].SubItems[4].Text;
65                     textBox4.Text = listView1.Items[i].SubItems[5].Text;
66                     richTextBox1.Text = listView1.Items[i].SubItems[1].Text;
67                     string t = listView1.Items[i].SubItems[6].Text.ToString().Trim();
68                     if (t.Length >= 2)
69                     {
70                         for (int ii = 0; ii < t.Length; ii++)
71                         {
72                             t2 = t[0].ToString();
73                             if (t[1].ToString() == "")
74                             {
75                                 t1 = "NULL";
76                             }
77                             else
78                             {
79                                 t1 = t[1].ToString();
80                             }
81                         }
82                     }
83                     else
84                     {
85                         t2 = t;
86                         t1 = "NULL";
87                     }
88                     Macdinh();
89                     if (t1 == "A")
90                     {
91                         checkBox1.Checked = true;
92                     }
93                     if (t1 == "B")
94                     {
95                         checkBox2.Checked = true;
96                     }
97                     if (t1 == "C")
98                     {
99                         checkBox3.Checked = true;
100                     }
101                     if (t1 == "D")
102                     {
103                         checkBox4.Checked = true;
104                     }
105
106                     if (t2 == "A")
107                     {
108                         checkBox1.Checked = true;
109                     }
110                     if (t2 == "B")
111                     {
112                         checkBox2.Checked = true;
113                     }
114                     if (t2 == "C")
115                     {
116                         checkBox3.Checked = true;
117                     }
118                     if (t2 == "D")
119                     {
120                         checkBox4.Checked = true;
121                     }
122                     bdapan = true;
123                 }
124                 if (bdapan == false)
125                 {
126                     Bandau();
127                 }
128             }
129
130         }
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: frmCapNhat.cs Copy
311         private void button4_Click(object sender, EventArgs e)
312         {
313             if (richTextBox1.Text == "" || textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == false && checkBox4.Checked == false))
314             {
315                 MessageBox.Show("Bạn chưa thêm đầy đủ thông tin", "Thông báo");
316             }
317             else
318             {
319                 try
320                 {
321
322                     string sCauA = textBox1.Text;
323                     string sCauB = textBox2.Text;
324                     string sCauC = textBox3.Text;
325                     string sCauD = textBox4.Text;
326                     string sMaCH = textBox5.Text;
327                     string sCauHoi = richTextBox1.Text;
328                     string sCauDung = "";
329                     string sCauDungLuu = "";
330                     string sTrinhDo = comboBox1.Text;
331                     if (checkBox1.Checked == true)
332                     {
333                         sCauDung = "A";
334                         sCauDungLuu += sCauDung;
335                     }
336                     if (checkBox2.Checked == true)
337                     {
338                         sCauDung = "B";
339                         sCauDungLuu += sCauDung;
340                     }
341                     if (checkBox3.Checked == true)
342                     {
343                         sCauDung = "C";
344                         sCauDungLuu += sCauDung;
345                     }
346                     if (checkBox4.Checked == true)
347                     {
348                         sCauDung = "D";
349                         sCauDungLuu += sCauDung;
350                     }
351
352                     sqlcmd = new SqlCommand("insert into dapan values('" + sMaCH + "','" + sCauA + "','" + sCauB + "','" + sCauC + "','" + sCauD + "','" + sCauDungLuu + "') ", sqlcon);
353                     sqlcmd.ExecuteNonQuery();
354                     sqlcmd = new SqlCommand("insert into cauhoi values('" + sMaCH + "','" + sCauHoi + "','" + sTrinhDo + "') ", sqlcon);
355                     sqlcmd.ExecuteNonQuery();
356                     LoadDataToListView();
357                     button4.Enabled = false;
358                 }
359                 //roi hen;de bi coi lai thu de cHOAky thu chay thu hen ok
360                 catch
361                 {
362                     MessageBox.Show("Bạn đã thao tác sai");
363                 }
364             }
365         }
File name: frmQuanLySinhVien.cs Copy
67         private void btnthem_Click(object sender, EventArgs e)
68         {
69             try
70             {
71             string mats = textBox1.Text;
72             string hoten = textBox2.Text;
73             string ngaysinh = textBox3.Text;
74             string gioitinh = textBox4.Text;
75             string quequan = textBox5.Text;
76             string sodt = textBox6.Text;
77             string email = textBox7.Text;
78
79             string strSQL = "insert SINHVIEN values('" + mats + "','" + hoten + "','" + ngaysinh + "','" + gioitinh + "','" + quequan + "','" + sodt + "','" + email + "')";
80             sqlcmd = new SqlCommand(strSQL, sqlcon);
81             sqlcmd.ExecuteNonQuery();
82             MessageBox.Show("B?n dã dang ký thành công");
83             load();
84             }
85                 catch
86             {
87                 MessageBox.Show("Trùng mã sinh viên !!!");
88                 }
89
90         }
File name: frmQuanLySinhVien.cs Copy
97         private void btnsua_Click(object sender, EventArgs e)
98         {
99             try
100             {
101                 string mats = textBox1.Text;
102                 string hoten = textBox2.Text;
103                 string ngaysinh = textBox3.Text;
104                 string gioitinh = textBox4.Text;
105                 string quequan = textBox5.Text;
106                 string sodt = textBox6.Text;
107                 string email = textBox7.Text;
108                 sqlcmd = new SqlCommand("update sinhvien set mats='" + mats + "',hoten='" + hoten + "',ngaysinh='" + ngaysinh + "',gioitinh='" + gioitinh + "',quequan='" + quequan + "',sodienthoai='" + sodt + "',email'" + email + "' ", sqlcon);
109                 sqlcmd.ExecuteNonQuery();
110
111                 load();
112             }
113             catch
114             {
115                 MessageBox.Show("Loi");
116             }
117         }
File name: frmQuanLySinhVien.cs Copy
128         private void listView1_SelectedIndexChanged(object sender, EventArgs e)
129         {
130             for (int i = 0; i < listView1.Items.Count; i++)
131                 if (listView1.Items[i].Selected)
132                 {
133                     textBox1.Text = listView1.Items[i].SubItems[0].Text;
134                     textBox2.Text = listView1.Items[i].SubItems[1].Text;
135                     textBox3.Text = listView1.Items[i].SubItems[2].Text;
136                     textBox4.Text = listView1.Items[i].SubItems[3].Text;
137                     textBox5.Text = listView1.Items[i].SubItems[4].Text;
138                     textBox6.Text = listView1.Items[i].SubItems[5].Text;
139                     textBox7.Text = listView1.Items[i].SubItems[6].Text;
140
141                 }
142         }
File name: Form1.cs Copy
254   public void NavRecords()
255   {
256
257    STUDID.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][1]);
258    TextBox1.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][2]);
259    TextBox2.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][3]);
260    TextBox3.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][4]);
261    TextBox4.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][5]);
262    TextBox5.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][6]);
263    TextBox6.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][7]);
264    TextBox7.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][8]);
265    TextBox8.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][9]);
266    TextBox9.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][10]);
267    TextBox10.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][11]);
268    TextBox11.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][12]);
269    TextBox12.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][13]);
270    TextBox13.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][14]);
271    TextBox14.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][15]);
272    TextBox15.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][16]);
273    TextBox16.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][17]);
274    TextBox17.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][18]);
275    TextBox18.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][19]);
276    TextBox19.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][20]);
277
278   }
File name: Form1.cs Copy
347   public void Button6_Click(System.Object sender, System.EventArgs e)
348   {
349
350    TextBox1.Text = DataGridView1.CurrentRow.Cells[1].Value.ToString();
351    TextBox2.Text = DataGridView1.CurrentRow.Cells[2].Value.ToString();
352    TextBox3.Text = DataGridView1.CurrentRow.Cells[3].Value.ToString();
353    TextBox4.Text = DataGridView1.CurrentRow.Cells[4].Value.ToString();
354    TextBox5.Text = DataGridView1.CurrentRow.Cells[5].Value.ToString();
355    TextBox6.Text = DataGridView1.CurrentRow.Cells[6].Value.ToString();
356    TextBox7.Text = DataGridView1.CurrentRow.Cells[7].Value.ToString();
357    TextBox8.Text = DataGridView1.CurrentRow.Cells[8].Value.ToString();
358    TextBox9.Text = DataGridView1.CurrentRow.Cells[9].Value.ToString();
359    TextBox10.Text = DataGridView1.CurrentRow.Cells[10].Value.ToString();
360    TextBox11.Text = DataGridView1.CurrentRow.Cells[11].Value.ToString();
361    TextBox12.Text = DataGridView1.CurrentRow.Cells[12].Value.ToString();
362    TextBox13.Text = DataGridView1.CurrentRow.Cells[13].Value.ToString();
363    TextBox14.Text = DataGridView1.CurrentRow.Cells[14].Value.ToString();
364    TextBox15.Text = DataGridView1.CurrentRow.Cells[15].Value.ToString();
365    TextBox16.Text = DataGridView1.CurrentRow.Cells[16].Value.ToString();
366    TextBox17.Text = DataGridView1.CurrentRow.Cells[17].Value.ToString();
367    TextBox18.Text = DataGridView1.CurrentRow.Cells[18].Value.ToString();
368    TextBox19.Text = DataGridView1.CurrentRow.Cells[19].Value.ToString();
369    STUDID.Text = DataGridView1.CurrentRow.Cells[0].Value.ToString();
370
371   }
File name: Form1.cs Copy
397   public void DataGridView1_CellDoubleClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
398   {
399    TextBox1.Text = DataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
400    TextBox2.Text = DataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
401    TextBox3.Text = DataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
402    TextBox4.Text = DataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
403    TextBox5.Text = DataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
404    TextBox6.Text = DataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
405    TextBox7.Text = DataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();
406    TextBox8.Text = DataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();
407    TextBox9.Text = DataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString();
408    TextBox10.Text = DataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString();
409    TextBox11.Text = DataGridView1.Rows[e.RowIndex].Cells[11].Value.ToString();
410    TextBox12.Text = DataGridView1.Rows[e.RowIndex].Cells[12].Value.ToString();
411    TextBox13.Text = DataGridView1.Rows[e.RowIndex].Cells[13].Value.ToString();
412    TextBox14.Text = DataGridView1.Rows[e.RowIndex].Cells[14].Value.ToString();
413    TextBox15.Text = DataGridView1.Rows[e.RowIndex].Cells[15].Value.ToString();
414    TextBox16.Text = DataGridView1.Rows[e.RowIndex].Cells[16].Value.ToString();
415    TextBox17.Text = DataGridView1.Rows[e.RowIndex].Cells[17].Value.ToString();
416    TextBox18.Text = DataGridView1.Rows[e.RowIndex].Cells[18].Value.ToString();
417    TextBox19.Text = DataGridView1.Rows[e.RowIndex].Cells[19].Value.ToString();
418    STUDID.Text = DataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
419
420
421   }

TextBox2 112 lượt xem

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