天天看点

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);//鼠标右键按下弹出菜单
    }

}