Windows Form Modeless Show

Hi folks,

I’ve being trying to code a no modal Windows Form in C# but it isn’t working as expected. If you click RMB then the context menu got frozen for user interaction via mouse. Only keyboard works in the context menu. After the context menu is closed then Solidworks works fine.

On the other hands the same approach works fine with VBA (form.Show VbModeless).

Could you help me on how should I code the Windows Form?

Here’s a code snippet in use that I got from GPT for a Windows Form:

Class Program()
{
  void Main()
  {
    MyForm().Wait();
  }
    
  async Task MyForm()
  {
    var formClosed = new TaskCompletionSource<bool>();
    
    var form = new ExampleForm();
    
    form.FormClosed += (s, e) => formClosed.SetResult(true);
    
    form.Show();
    
    System.Windows.Forms.Application.Run(form);
    
    await formClosed.Task;
  }
}

WinForms has Show and ShowDialog. Those are all you need.

You’re probably looking for ShowDialog.