title: Passing through current form instance to another Class
body: <p>I have come across an issue i'm unable to solve, i'm trying to pass through to a class an instance of the form <code>this</code>.</p>
  <p>My code:</p>
  <pre><code>namespace newapplication
  {
      public partial class FormBrowser : Form
      {
          public ChromiumWebBrowser browser;
          private ChromeDriver _driver;
          private readonly FormMain _formMain;
          public static ClassProject _project;
          public static string _mode;
          private readonly string[] _sites;
          private static int counter = 0;
          private static int sitesCount = 0;
          public bool useSelenium = false;
          public bool useDebugJS = false;
  
          public FormBrowser(string[] sites, string mode, FormMain formMain, ClassProject project)
          {
              InitializeComponent();
              InitializeBrowser(sites, project);
  
              _formMain = formMain;
              _mode = mode;
              _sites = sites;
              _project = project;
          }
  
          private FormBrowser _formBrowser;
          public class MyCustomMenuHandler : IContextMenuHandler
          {
              public void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
              {
                  // Remove any existent option using the Clear method of the model.
                  model.Clear();
  
                  if (model.Count &gt; 0)
                  {
                      model.AddSeparator();
                  }
  
                  model.AddItem((CefMenuCommand)26508, &quot;Copy text ...&quot;);
                  model.AddItem((CefMenuCommand)26509, &quot;Paste text ...&quot;);
                  model.AddSeparator();
                  model.AddItem((CefMenuCommand)26501, &quot;Open chrome devtools ...&quot;);
                  model.AddItem((CefMenuCommand)26502, &quot;Open email verifier ...&quot;);
                  model.AddSeparator();
                  model.AddItem((CefMenuCommand)26503, &quot;Copy current URL ...&quot;);
                  model.AddSeparator();
                  model.AddItem((CefMenuCommand)26504, &quot;Save selected text to [REG] flags ...&quot;);
                  model.AddItem((CefMenuCommand)26505, &quot;Save selected text to [LAP] flags ...&quot;);
                  model.AddItem((CefMenuCommand)26506, &quot;Save selected text to email link flags ...&quot;);
                  model.AddItem((CefMenuCommand)26507, &quot;Save selected text to email link ignore flags ...&quot;);
              }
  
              public bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
              {
                  if (commandId == (CefMenuCommand)26501)
                  {
                      browser.GetHost().ShowDevTools();
                      return true;
                  }
  
                  if (commandId == (CefMenuCommand)26502)
                  {
                      FormEmailsActivation fea = new FormEmailsActivation(_formBrowser);
                      fea.Show();
                      return true;
                  }
  
                  if (commandId == (CefMenuCommand)26503)
                  {
                      if (_mode == &quot;MODE_LAP&quot;)
                      {
                          UpdatePostedLink(_project, _formBrowser);
                      }
                      else
  </code></pre>
  <p>I'm trying to pass through an instance of the current form:</p>
  <pre><code>private FormBrowser _formBrowser;
  </code></pre>
  <p>to this class:</p>
  <pre><code>public class MyCustomMenuHandler : IContextMenuHandler
  </code></pre>
  <p>I thought i could do:</p>
  <pre><code>public class MyCustomMenuHandler : IContextMenuHandler(_formBrowser)
  </code></pre>
  <p>But this is just showing a lot of errors I cannot even list (it was just an attempt to try something)</p>
  <p>I am totally stumped on how to get the form instance through so it's value won't be null.</p>
  <p>The answer is probably staring me in the face, any tips on this would be appreciated.</p>