title: Winforms call function from main form
body: <p>I've got a main form open and the main form contains a couple dropdown menus (comboBoxes) that are linked to either a text file (if it exists) or an internal text file (default). The function is like this:</p>
  
  <pre><code>public void readFiles()
  {
      string regionPath = @"C:\Users\" + Environment.UserName + @"\Regions.txt";
      string salesPath = @"C:\Users\" + Environment.UserName + @"\SalesReps.txt";
      Stream fileStream;
      Stream fileStream1;
  
      if (File.Exists(regionPath))
      {
          Console.WriteLine("Regions file exists");
          fileStream = File.Open(regionPath, FileMode.Open);
      }
      else
      {
          Console.WriteLine("Regions file does not exist");
          var resourceRegions = "SalesMap.Regions.txt";
          var assembly = Assembly.GetExecutingAssembly();
  
          fileStream = assembly.GetManifestResourceStream(resourceRegions);
      }
  
      using (StreamReader reader = new StreamReader(fileStream))
      {
          var lines = new List&lt;string[]&gt;();
          int Row = 0;
          while (!reader.EndOfStream)
          {
              string[] Line = reader.ReadLine().Split(',');
              RegionNames.Add(Line[0]);
              RegionParts.Add(Line[1]);
              Row++;
          }
      }
  
      if (File.Exists(salesPath))
      {
          Console.WriteLine("SalesReps file exists");
          fileStream1 = File.Open(salesPath, FileMode.Open);
      }
      else
      {
          Console.WriteLine("SalesReps file does not exist");
          var resourceSales = "SalesMap.SalesReps.txt";
          var assembly1 = Assembly.GetExecutingAssembly();
  
          fileStream1 = assembly1.GetManifestResourceStream(resourceSales);
      }
  
      using (StreamReader reader1 = new StreamReader(fileStream1))
      {
          var lines = new List&lt;string[]&gt;();
          int Row = 0;
          while (!reader1.EndOfStream)
          {
              string[] Line = reader1.ReadLine().Split(',');
              SalesRepNames.Add(Line[0]);
              SalesRepEmails.Add(Line[1]);
              SalesRepPhones.Add(Line[2]);
              SalesRepRegions.Add(Line[3]);
              Console.WriteLine(Row);
              Row++;
          }
      }
  
      comboBoxState.DataSource = RegionNames;
      comboBoxRepresentative.DataSource = SalesRepNames;
  
      labelRepResult2.Text = "";
      labelContactResult2.Text = "";
  }
  </code></pre>
  
  <p>I've also got a "settings" form and I want a button on the settings form to run this function on the main form (thereby forcing the dropdown menus on the main form to refresh their data).</p>
  
  <p>Any suggestions?</p>