title: Accessing string from another Form
body: <p>Hello I have datagridview in form1 and through form1 I open form2 and through form2 I open form3 and <code>string named vyber_ID_K</code> placed in Form1 needs to be accessed in Form3 (I need to get its value in Form3)</p>
  
  <p>this is placed on button click in form1</p>
  
  <pre><code> form2 a = new form2 ("Novy");
          string vyber_IDK = (string)dataGridView1.CurrentRow.Cells["ID_K"].Value.ToString();
          a.vyber_ID_K = vyber_IDK;
          a.Show();
          a.Closed += klient_Closed;
  </code></pre>
  
  <p>I would like to access <code>vyber_ID_K in form 3</code>, how it can be done? I tried to set <code>public string vyber_ID_K in form2 and pass it similary to form3 but I get null</code>. Am I doing it right? Is there any other better solution please?</p>
  
  <p>Thanks in advance.</p>
  
  <p>My step-by-step according to Servy:</p>
  
  <ol>
  <li><p>button click in Form 1 </p>
  
  <p>Func vyberIDKGetter = () => dataGridView1.CurrentRow.Cells["ID_K"].Value.ToString();</p>
  
  <pre><code>    try
      {
      form2 = new form2 ("Novy");
  
      a.vyberIDKGetter = () =&gt; dataGridView1.CurrentRow.Cells["ID_K"].Value.ToString();
      a.Show();
  </code></pre>
  
  <p>}</p></li>
  <li><p>button click in form2 </p>
  
  <p>public Func vyberIDKGetter;
  private void button1_Click(object sender, EventArgs e)
      {
      nova_platba b = new nova_platba("novy");
      b.vyberIDKGetter();
      b.Show();
      b.Closed += klient_Closed;
    }</p></li>
  <li><p>In form3</p>
  
  <pre><code>Func&lt;string&gt; vyberIDKGetter = veberIDK;
  
  
     string vyberIDK = vyberIDKGetter();
           SqlCommand sc = new SqlCommand(@"
              INSERT INTO kliplat (datum,text,castka,akce,subkey,priznak,rocnik) 
              VALUES (@datum,@text,@castka,@akce,@subkey,@priznak,@rocnik);
              SELECT scope_identity();
              ", spojeni);
  
  
       sc.Parameters.AddWithValue("@subkey", vyberIDK);
  </code></pre></li>
  </ol>