title: Refresh Form1 after closing Form2
body: <p>I want to refresh my datagrid in Form1 after I updated the database in Form2. My Problem is that it isn't updating the datagrid in Form1 after i close Form2. Literally I am not sure how to do that. Can someone help me please?</p>
  
  <p>This is how i create my datagrid (in Form1):</p>
  
  <pre><code>LagerDBEntities1 dataEntities = new LagerDBEntities1();          
  var query =
     from product in dataEntities.Artikel
     select new { product.Id, product.artikelname, product.bestand };            
     dataGrid1.ItemsSource = query.ToList();
  </code></pre>
  
  <p>This is how i switch to Form2:</p>
  
  <pre><code>Window2 Auslagern = new Window2(currbestand, artikelid, artikelname);
  this.Close();
  Auslagern.Show();
  </code></pre>
  
  <p>This is how i switch to Form1:</p>
  
  <pre><code>MainWindow Main = new MainWindow();
  this.Close();
  Main.Show();
  </code></pre>
  
  <p>In Form2 I am updating the database:</p>
  
  <pre><code>int counter = currentbestand - ValueS;
  if (counter &gt; 0)
      {
              SqlConnection con = new SqlConnection(@"X");
              try
              {
  
                  con.Open();
                  string Query = "update Artikel set bestand='" + counter + "' where id='" + artikelid + "' ";
                  SqlCommand createCommand = new SqlCommand(Query, con);
                  createCommand.ExecuteNonQuery();                    
                  con.Close();
              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.Message);
              }
  
              MainWindow Main = new MainWindow();
              this.Close();
              Main.Show();
  
  
          }
  </code></pre>
  
  <p>So how can I switch back to Form1 and see the updated datagrid?</p>
  
  <p>Thanks in advance!</p>