title: C# - Call a function in a parent form
body: <p>I'm trying to call a function in a main form from another form... Already got to call a simple function, by declaring it public static in main form, yet I can't call the needed one.
  The function to call:</p>
  
  <pre><code>    public static void spotcall()
      {
          string dial = Registry.CurrentUser.OpenSubKey("SOFTWARE").OpenSubKey("INTERCOMCS").GetValue("DIAL").ToString();
          MainForm.txtSendKeys.Text = dial;// Here it asks me for a reference to an object.
  
  
          foreach (char c in txtSendKeys.Text)
          {
              sideapp.Keyboard.SendKey(c.ToString(), checkBoxPrivate.Checked);
          }
          txtSendKeys.Clear();
      }
  </code></pre>
  
  <p>The procedure I use to call it from a child form:</p>
  
  <pre><code>    private void button1_Click(object sender, EventArgs e)
      {
          button1.Text = "Hoho";
          MainForm.spotcall();
      }
  </code></pre>
  
  <p>I completely admit that I lack some theory about C#, but as it often happens, I just have to do it for my work, so I expect to get help if by chance I don't get to the solution by myself. Thank you :)</p>