示例#1
0
 private void BtnDEL_Click(object sender, EventArgs e)
 {
     if (lbDS.SelectedItems.Count != 0)
     {
         while (lbDS.SelectedIndices.Count != 0)
         {
             if (DialogResult.Yes ==
                 MessageBox.Show("Bạn có muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
             {
                 for (int i = 0; i < lbDS.SelectedIndices.Count; i++)
                 {
                     DS.RemoveAt(lbDS.SelectedIndex);
                 }
                 lbDS.Items.Clear();
                 stt = 1; string a = " ";
                 for (int i = 0; i < lbDS.SelectedIndices.Count; i++)
                 {
                     foreach (object GTs in lbGT.SelectedItems)
                     {
                         a += GTs.ToString() + ", ";
                     }
                 }
                 foreach (object gt in DS)
                 {
                     lbDS.Items.Add(stt + " | " + gt);
                     stt++;
                 }
             }
         }
     }
     else
     {
         MessageBox.Show("Bạn cần chọn item để xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
示例#2
0
 private void BtnDK_Click(object sender, EventArgs e)
 {
     stt += 1;
     if (txtHT.TextLength == 0 || cmbKhoa.Text == null || cmbYear.Text == null)
     {
         MessageBox.Show("Vui lòng nhập đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         string a = " ";
         foreach (object GTs in lbGT.SelectedItems)
         {
             a += GTs.ToString() + ", ";
         }
         lbDS.Items.Add(+stt + " | " + txtHT.Text + " | " + cmbKhoa.Text + " | " +
                        cmbYear.Text + " | " + "ĐK: " + a);
         DS.Add(txtHT.Text + " | " + cmbKhoa.Text + " | " +
                cmbYear.Text + " | " + "ĐK: " + a);
     }
 }