天天看點

C#添加listBox右鍵菜單

C#添加​

​listBox​

​右鍵菜單

/// <summary>
/// listBox右鍵菜單
/// </summary>
private void chklbxItem_MouseUp(object sender, MouseEventArgs e)
{
    ContextMenuStrip strip = new ContextMenuStrip();
    strip.Items.Add("item1");
    strip.Items.Add("item2");
    if (e.Button == MouseButtons.Right)
    {
        strip.Show(this.chklbxItem, e.Location);//滑鼠右鍵按下彈出菜單
    }

}