title: c# how change a variable from another class
body: <p>I have a variabele called 'language' in the main form of my windows form application.</p>
  
  <p>In a sub-form I have a combo box with which I need to change the value of 'language' <strong>without making a new instance of the main form</strong></p>
  
  <pre><code>namespace MMI_WFA
  {
      public partial class MainWindow : Form
      {
          int language;
              ...
              ...
      }
  }
  
  
  namespace MMI_WFA
  {
      public partial class MENU : Form
      {
      ...
  
          private void cbo_Language_SelectedIndexChanged(object sender, EventArgs e)
          {
              function_to_Change_language_in_mainForm();
          }
      }
  }
  </code></pre>
  
  <p>So can I change a variable in the main form, with an event of an other form?</p>
  
  <p>EDIT: I change this but window in <code>this.window</code>has red underlines.</p>
  
  <pre><code>public MENU(MainWindow window) // main constructor
          {
              this.window = window;
              InitializeComponent();
              cbo_SerialPort.Items.AddRange(ports);
              //cbo_SerialPort.SelectedIndex = 2;           
  
              cbo_Baudrate.Items.AddRange(baudrates);
              //cbo_Baudrate.SelectedIndex = 1;
  
              cbo_ParityBits.Items.AddRange(partitybits);
              //cbo_ParityBits.SelectedIndex = 0;
  
              hideExtraSettings();
              fillLanguageBox();
              indexComboboxes();
          }
  </code></pre>