Esempio n. 1
0
        public void setValue(string name, List <ItemTDLs> item)
        {
            _flag = 0;
            eitem = new List <ItemTDLs>(item);
            _STT  = eitem[eitem.Count - 1].STT;
            this.txtTittle.Text = name;
            foreach (ItemTDLs t in eitem)
            {
                ItemTDL i = new ItemTDL();
                i.Name = _flag.ToString();
                i.setValue(t.Content, t.STT, t.check);
                _flag++;
                i.edit();
                this.flowLayoutPanel1.Controls.Add(i);

                i.checkbox.Enter += (s, e) =>
                {
                    type      = 1;
                    _isDelete = 0;
                    //STT = Int32.Parse(i.checkbox.Name);
                    _e = Int32.Parse(i.Name);
                    //Console.WriteLine(_e);
                    save = eitem.ElementAt(_e);
                    Console.WriteLine("_e " + _e);
                };

                i.checkbox.Leave += (s, e) =>
                {
                    if (_isDelete == 0)
                    {
                        save.check = i.checkbox.Checked;
                        eitem.RemoveAt(_e);
                        eitem.Insert(_e, save);
                    }
                };

                i.textBox1.Enter += (s, e) =>
                {
                    type      = 1;
                    _isDelete = 0;
                    //STT = Int32.Parse(i.checkbox.Name);
                    _e = Int32.Parse(i.Name);
                    //Console.WriteLine(_e);
                    save = eitem.ElementAt(_e);
                    Console.WriteLine("_e " + _e);
                };

                i.textBox1.Leave += (s, e) =>
                {
                    if (_isDelete == 0)
                    {
                        save.Content = i.textBox1.Text;
                        eitem.RemoveAt(_e);
                        eitem.Insert(_e, save);
                    }
                };
            }
        }
Esempio n. 2
0
        private void pictureBox1_Click(object sender, EventArgs g)
        {
            _isDelete = 1;
            if (_e < 0)
            {
                MessageBox.Show("Vui lòng chọn dòng để xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                if (type == 1)
                {
                    deletedItem.Add(eitem.ElementAt(_e));
                    eitem.RemoveAt(_e);
                }
                else
                {
                    newitem.RemoveAt(_e);
                }
                this.flowLayoutPanel1.Controls.Clear();
                _flag  = 0;
                _flag2 = 0;

                foreach (ItemTDLs t in eitem)
                {
                    ItemTDL i = new ItemTDL();
                    i.Name = _flag.ToString();
                    i.setValue(t.Content, t.STT, t.check);
                    _flag++;
                    i.edit();
                    this.flowLayoutPanel1.Controls.Add(i);

                    i.checkbox.Enter += (s, e) =>
                    {
                        type      = 1;
                        _isDelete = 0;
                        //STT = Int32.Parse(i.checkbox.Name);
                        _e = Int32.Parse(i.Name);
                        //Console.WriteLine(_e);
                        save = eitem.ElementAt(_e);
                        Console.WriteLine("_e " + _e);
                        Console.WriteLine("STT " + i.textBox1.Name);
                    };

                    i.checkbox.Leave += (s, e) =>
                    {
                        if (_isDelete == 0)
                        {
                            save.check = i.checkbox.Checked;
                            eitem.RemoveAt(_e);
                            eitem.Insert(_e, save);
                        }
                    };

                    i.textBox1.Enter += (s, e) =>
                    {
                        type      = 1;
                        _isDelete = 0;
                        //STT = Int32.Parse(i.checkbox.Name);
                        _e = Int32.Parse(i.Name);
                        //Console.WriteLine(_e);
                        save = eitem.ElementAt(_e);
                        Console.WriteLine("_e " + _e);
                        Console.WriteLine("STT " + i.textBox1.Name);
                    };

                    i.textBox1.Leave += (s, e) =>
                    {
                        if (_isDelete == 0)
                        {
                            save.Content = i.textBox1.Text;
                            eitem.RemoveAt(_e);
                            eitem.Insert(_e, save);
                        }
                    };
                }

                foreach (ItemTDLs t in newitem)
                {
                    ItemTDL i = new ItemTDL();
                    i.Name = _flag2.ToString();
                    i.setValue(t.Content, t.STT, t.check);
                    _flag2++;
                    i.edit();
                    this.flowLayoutPanel1.Controls.Add(i);

                    i.checkbox.Enter += (s, e) =>
                    {
                        type      = 2;
                        _isDelete = 0;
                        _e        = Int32.Parse(i.Name);
                        //Console.WriteLine(_e);
                        save = newitem.ElementAt(_e);
                        Console.WriteLine("_e " + _e);
                        Console.WriteLine("STT " + i.textBox1.Name);
                    };

                    i.checkbox.Leave += (s, e) =>
                    {
                        if (_isDelete == 0)
                        {
                            save.check = i.checkbox.Checked;
                            newitem.RemoveAt(_e);
                            newitem.Insert(_e, save);
                        }
                    };

                    i.textBox1.Enter += (s, e) =>
                    {
                        type      = 2;
                        _isDelete = 0;
                        _e        = Int32.Parse(i.Name);
                        //Console.WriteLine(_e);
                        save = newitem.ElementAt(_e);
                        Console.WriteLine("_e " + _e);
                        Console.WriteLine("STT " + i.textBox1.Name);
                    };

                    i.textBox1.Leave += (s, e) =>
                    {
                        if (_isDelete == 0)
                        {
                            save.Content = i.textBox1.Text;
                            newitem.RemoveAt(_e);
                            newitem.Insert(_e, save);
                        }
                    };
                }
            }
        }
Esempio n. 3
0
        private void pictureBox2_Click(object sender, EventArgs g)
        {
            newitem.Add(new ItemTDLs()
            {
                STT     = _STT + 1,
                check   = false,
                Content = "Write Something"
            });

            ItemTDL i = new ItemTDL();

            i.Name = _flag2.ToString();
            i.setValue("Write Something", _STT + 1, false);
            i.edit();

            _flag2++;
            _STT++;

            this.flowLayoutPanel1.Controls.Add(i);

            i.checkbox.Enter += (s, e) =>
            {
                type      = 2;
                _isDelete = 0;
                _e        = Int32.Parse(i.Name);
                //Console.WriteLine(_e);
                save = newitem.ElementAt(_e);
                //Console.WriteLine("_e " + _e);
                //Console.WriteLine("STT " + i.textBox1.Name);
            };

            i.checkbox.Leave += (s, e) =>
            {
                if (_isDelete == 0)
                {
                    save.check = i.checkbox.Checked;
                    newitem.RemoveAt(_e);
                    newitem.Insert(_e, save);
                }
            };

            i.textBox1.Enter += (s, e) =>
            {
                type      = 2;
                _isDelete = 0;
                _e        = Int32.Parse(i.Name);
                //Console.WriteLine(_e);
                save = newitem.ElementAt(_e);
                //Console.WriteLine("_e " + _e);
                //Console.WriteLine("STT " + i.textBox1.Name);
            };

            i.textBox1.Leave += (s, e) =>
            {
                if (_isDelete == 0)
                {
                    save.Content = i.textBox1.Text;
                    newitem.RemoveAt(_e);
                    newitem.Insert(_e, save);
                }
            };
        }