Hi All,
I have created two forms in my Windows Application.
One Form acts as a Form and the other form acts as a MODAL DIALOG BOX.
The Form Dialog Box contains a button and One textBox. When this button is clicked the MODAL DIALOGBOX should be displayed. This dialog box also contains One Textbox and Two Buttons(Ok and Cancel).
Now when this dialog box is displayed the TextBox of the dialog box should contain the value entered in the textbox of Form1.
I have used the following coding to accomplish this task. Form1 Coding:
public string UserName;
private void btnFn_Click(object sender, EventArgs e)
{
UserName = txtUserName.Text;
frmFnC objFnC = new frmFnC();
objFnC.ShowDialog();
objFnC.txtUserName.Text = UserName;
}
Code in MODAL DIALOGBOX OK button:
Please note that the Cancel button is enabled only when the OK button is clicked.
Coding:
private void btnOk_Click(object sender, EventArgs e)
{
btnCancel.Enabled=true;
}
private void btnCancel_Click(object sender,EventArgs e)
{
this.Close();
}
The problem I am facing is the value entered by the User in the USERNAME textbox is not displayed in the TEXTBOX in the MODAL DIALOG BOX. Instead it is displaying the textbox as empty.
What should I do to get the values entered by the user in the textbox to this modal dialog box?
Can anybody help me out in performing the desired task?
Thanks in advance!!!