Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In order to be able to set (and get) the contents of the text box in the modal form, add this code to that form:</p> <pre><code>public string UserName { get { return txtUserName.Text; } set { txtUserName.Text = value; } } </code></pre> <p>Then, in the other form, you can set the user name:</p> <pre><code>frmFnC objFnC = new frmFnC(); objFnC.UserName = txtUserName.Text; objFnC.ShowDialog(); </code></pre> <p>I also need to ask you about the relation between the OK and Cancel buttons in the modal dialog form; it seems a bit wierd the user would need to first click OK, in order to get the Cancel button enabled, and then click Cancel to actually close the form.</p> <p>I would suggest to not have any event handlers for the click events of these buttons, but instead set the appropriate values of their <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.button.dialogresult.aspx" rel="nofollow noreferrer"><code>DialogResult</code></a> property, and then set the modal form's <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.acceptbutton.aspx" rel="nofollow noreferrer"><code>AcceptButton</code></a> and <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.cancelbutton.aspx" rel="nofollow noreferrer"><code>CancelButton</code></a> properties. That way you can check how the dialog was closed:</p> <pre><code>frmFnC objFnC = new frmFnC(); objFnC.UserName = txtUserName.Text; if (objFnC.ShowDialog() == DialogResult.OK) { // the user clicked the OK button } else { // the user clicked the Cancel button } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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