Note that there are some explanatory texts on larger screens.

plurals
  1. POSending Data from child form to Parent Form TextBox
    text
    copied!<p>I have a Parent Form that holds a "HUD" with First Name, Last Name, etc. One of the child forms is a Search Form. When the user selects a member from the results that are displayed in a DataGrid I want the pertinent information to fill in the HUD. I created a HUD class with variables for each value and a method called UpdateHUD(). I am unsure how to get this working. I have a reference to the Search Form of the Parent form containing the HUD, like so:</p> <pre><code>public frmWWCModuleHost _frmWWCModuleHost; </code></pre> <p>This is the code I use to embed forms. I am not using MDI.</p> <pre><code> public static void ShowFormInContainerControl(Control ctl, Form frm) { frm.TopLevel = false; frm.FormBorderStyle = FormBorderStyle.None; frm.Dock = DockStyle.Fill; frm.Visible = true; ctl.Controls.Add(frm); } </code></pre> <p>Here is the code I am running on Cell Click on the Search Form. This is from before I tried implementing the HUD class.</p> <pre><code>private void dgvSearchResults_CellContentClick(object sender, DataGridViewCellEventArgs e) { _frmWWCModuleHost = new frmWWCModuleHost(); _frmWWCModuleHost.tbxHUD_LastName.Text = dgvSearchResults.CurrentRow.Cells[1].FormattedValue.ToString(); _frmWWCModuleHost.tbxHUD_LastName.Invalidate(); _frmWWCModuleHost.FormPaint(); } </code></pre> <p>Thanks in advance!</p> <p>~ Patrick</p> <hr> <h2>EDIT</h2> <hr> <p>dgvSearchResults_CellContentClick is now current. When I step through this code it is getting the correct Value here but it is never updating the actual HUD. </p> <hr> <h2>EDIT 2</h2> <hr> <p>Is my problem that I am declaring a NEW frmWWCModuleHost instead of passing a ref to the existing? I am still pretty weak in my understanding of this.</p> <hr> <h2>EDIT 3</h2> <hr> <p>I have "solved" this by doing the following: On the Parent Form where I declare the Child Form I pass <em>this</em> as a param. Then in the constructor of the child form I added _frmWWCModuleHost = m_parent; I have a UpdateHUD() method on my Parent form and I call it from the _CellClick event on the child.</p> <p>Now to rephrase my question; Is there anything glaringly wrong with doing it this way?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload