我在FlowLayoutPanel上动态添加了Label,代码如下:
private void button1_Click(object sender, EventArgs e)
{
Label lb = new Label();
lb.Text = "How are You";
lb.Size = new Size(650, Font.Height +10);
flowLayoutPanel1.Controls.Add(lb);
flowLayoutPanel1.SetFlowBreak(lb, true);
lb.BackColor = Color.Wheat;
}
在ContextMenuStrip我添加了两个 Item Add 和 Edit 并将其关联FlowLayoutPanel,这意味着当用户右键单击FlowLayoutPanel时,会出现 Edit 和 Remove 菜单。
现在我想使用删除按钮(ContextMenuStrip)删除动态添加标签。我只想右键单击欲望标签,右键单击后应该将其删除。与编辑按钮相同的情况进行编辑。