public Form_FavForlder(FavForlder forlder_) { InitializeComponent(); BackColor = Color.FromArgb(216, 229, 250); forlder = forlder_; textBox2.Text = forlder.forlder_name; }
//文件夹 void dropbutton_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { FavForlder forlder = (FavForlder)((ToolStripDropDownButton)sender).Tag; forlder.tag = sender; contextMenuStrip2.Tag = forlder; contextMenuStrip2.Show(Cursor.Position); } }
private void 编辑EToolStripMenuItem2_Click(object sender, EventArgs e) { FavForlder forlder = (FavForlder)contextMenuStrip2.Tag; if (new Form_FavForlder(forlder).ShowDialog() == DialogResult.OK) { ((ToolStripDropDownButton)forlder.tag).Text = Form_FavForlder.forlder.forlder_name; ((ToolStripDropDownButton)forlder.tag).Tag = Form_FavForlder.forlder; } }
private void 除DToolStripMenuItem1_Click(object sender, EventArgs e) { FavForlder forlder = (FavForlder)contextMenuStrip2.Tag; if (MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Mdb.DeleteForlder(forlder.id); toolStrip1.Items.Remove((ToolStripDropDownButton)forlder.tag); } }
private void button1_Click(object sender, EventArgs e) { if (textBox2.Text == "") { textBox2.Focus(); return; } forlder = forlder == null?Mdb.AddForlder(textBox2.Text) : Mdb.UpdateForlder(forlder.id, textBox2.Text); DialogResult = DialogResult.OK; }
private void 新建文件夹MToolStripMenuItem_Click(object sender, EventArgs e) { if (new Form_FavForlder().ShowDialog() == DialogResult.OK) { FavForlder forlder = Form_FavForlder.forlder; ToolStripDropDownButton dropbutton = new ToolStripDropDownButton(forlder.forlder_name, imageList2.Images[0]); dropbutton.Tag = forlder; dropbutton.MouseUp += new MouseEventHandler(dropbutton_MouseUp); ToolStripMenuItem item = new ToolStripMenuItem("添加到本文件夹", null, new EventHandler(AddFavButton_Click)); dropbutton.DropDownItems.Add(item); item.Tag = forlder.id; ToolStripSeparator separator = new ToolStripSeparator(); dropbutton.DropDownItems.Add(separator); toolStrip1.Items.Insert(13, dropbutton); } }