How to have both forms accessible at the same time

0

I'd like to have two forms accessible at the same time, meaning that I can click on the main form without closing the second form.

Here's how I'm currently doing for example to show a form after a right click but I get an exception:

// In main form
private void contextMenuStrip1_Click(object sender, EventArgs e)
{
    RightClickMenu.GetInstance().Show(); // works but exception System.ObjectDisposedException (HResult=0x80131622) if I try to open it a second time after RightClickMenu : Form
    // RightClickMenu.GetInstance().ShowDialog(); // can't have both forms accessible at the same time
}


// In second form   
public partial class RightClickMenu : Form
{
    public static RightClickMenu GetInstance()
    {
        if (_RightClickMenu == null)
        {
            _RightClickMenu = new RightClickMenu();
        }
        return _RightClickMenu;
    }

    public RightClickMenu()
    {
        InitializeComponent();
    }

    private void buttonQuit_Click(object sender, EventArgs e)
    {
        this.Close();
    }
}

Thanks

c#
forms
winforms
asked on Stack Overflow Jan 30, 2020 by PLB

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0