public Project() { save = new ItemProjects(); deletedItem = new List <ItemProjects>(); InitializeComponent(); this.lbTime.Visible = false; }
private void btnAdd_Click(object sender, EventArgs g) { newitem.Add(new ItemProjects() { STT = _STT + 1, check = false, Content = "Write Something" }); EditItem i = new EditItem(); i.Name = _flag2.ToString(); i.setValue(_STT + 1, "Write Something", false); _flag2++; _STT++; this.flowLayoutPanel1.Controls.Add(i); i.checkBox.Enter += (s, e) => { type = 2; _isDelete = 0; _e = Int32.Parse(i.Name); Console.WriteLine("_e " + _e); Console.WriteLine("STT " + i.textBox.Name); save = newitem.ElementAt(_e); }; i.checkBox.Leave += (s, e) => { if (_isDelete == 0) { save.check = i.checkBox.Checked; newitem.RemoveAt(_e); newitem.Insert(_e, save); } }; i.textBox.Enter += (s, e) => { type = 2; _isDelete = 0; _e = Int32.Parse(i.Name); Console.WriteLine("_e " + _e); Console.WriteLine("STT " + i.textBox.Name); save = newitem.ElementAt(_e); }; i.textBox.Leave += (s, e) => { if (_isDelete == 0) { save.Content = i.textBox.Text; newitem.RemoveAt(_e); newitem.Insert(_e, save); } }; }
private void btnEdit_Click(object sender, EventArgs g) { _STT = item[item.Count - 1].STT; newitem = new List <ItemProjects>(); _flag = 0; _flag2 = 0; this.btnEdit.Visible = false; this.btnTimer.Visible = true; this.lbProjectName.Visible = false; this.txtTittle.Visible = true; this.lbComplete.Visible = false; this.lbTime.Visible = false; btnOK.Visible = true; btnDel.Visible = true; btnCancel.Visible = true; btnAdd.Visible = true; this.panel1.Visible = false; this.flowLayoutPanel1.Controls.Clear(); foreach (ItemProjects t in item) { EditItem i = new EditItem(); i.Name = _flag.ToString(); i.setValue(t.STT, t.Content, t.check); _flag++; this.flowLayoutPanel1.Controls.Add(i); i.checkBox.Enter += (s, e) => { type = 1; _isDelete = 0; _e = Int32.Parse(i.Name); save = item.ElementAt(_e); Console.WriteLine("_e " + _e); }; i.checkBox.Leave += (s, e) => { if (_isDelete == 0) { save.check = i.checkBox.Checked; item.RemoveAt(_e); item.Insert(_e, save); } }; i.textBox.Enter += (s, e) => { type = 1; _isDelete = 0; _e = Int32.Parse(i.Name); Console.WriteLine("_e " + _e); save = item.ElementAt(_e); }; i.textBox.Leave += (s, e) => { if (_isDelete == 0) { save.Content = i.textBox.Text; item.RemoveAt(_e); item.Insert(_e, save); } }; } }
private void addNewEditItem() { if (type == 1) { deletedItem.Add(item.ElementAt(_e)); item.RemoveAt(_e); } else { newitem.RemoveAt(_e); } this.flowLayoutPanel1.Controls.Clear(); _flag = 0; _flag2 = 0; foreach (ItemProjects t in item) { EditItem i = new EditItem(); i.Name = _flag.ToString(); i.setValue(t.STT, t.Content, t.check); _flag++; this.flowLayoutPanel1.Controls.Add(i); i.checkBox.Enter += (s, e) => { type = 1; _isDelete = 0; _e = Int32.Parse(i.Name); save = item.ElementAt(_e); Console.WriteLine("_e " + _e); }; i.checkBox.Leave += (s, e) => { if (_isDelete == 0) { save.check = i.checkBox.Checked; item.RemoveAt(_e); item.Insert(_e, save); } }; i.textBox.Enter += (s, e) => { type = 1; _isDelete = 0; _e = Int32.Parse(i.Name); Console.WriteLine("_e " + _e); save = item.ElementAt(_e); }; i.textBox.Leave += (s, e) => { if (_isDelete == 0) { save.Content = i.textBox.Text; item.RemoveAt(_e); item.Insert(_e, save); } }; } foreach (ItemProjects t in newitem) { EditItem i = new EditItem(); i.Name = _flag2.ToString(); i.setValue(t.STT, t.Content, t.check); _flag2++; this.flowLayoutPanel1.Controls.Add(i); i.checkBox.Enter += (s, e) => { type = 2; _isDelete = 0; _e = Int32.Parse(i.Name); Console.WriteLine("_e " + _e); Console.WriteLine("STT " + i.textBox.Name); save = newitem.ElementAt(_e); }; i.checkBox.Leave += (s, e) => { if (_isDelete == 0) { save.check = i.checkBox.Checked; newitem.RemoveAt(_e); newitem.Insert(_e, save); } }; i.textBox.Enter += (s, e) => { type = 2; _isDelete = 0; _e = Int32.Parse(i.Name); Console.WriteLine("_e " + _e); Console.WriteLine("STT " + i.textBox.Name); save = newitem.ElementAt(_e); }; i.textBox.Leave += (s, e) => { if (_isDelete == 0) { save.Content = i.textBox.Text; newitem.RemoveAt(_e); newitem.Insert(_e, save); } }; } }