1
Reply

passing vlaue from 1 form to another

rsuguna1

rsuguna1

May 16 2005 1:20 AM
1.7k
i'm trying to get a value from the textbox in Form A, FormWizIntervalTime and store it in a container class, ScheduleContainer. The stored value is retrived by Form B, FormWizConfirm into a txtbox. I have used property to get n set the values in ScheduleContainer. here r the codes... In Form A: class FormWizIntervalTime { ..... private void txtScdName_Validating(object sender, System.ComponentModel.CancelEventArgs e) { //yewchong - You declare a new object here, so new memory is being assigned ScheduleContainer strName = new ScheduleContainer(); strName.SetScheduleName = txtScdName.Text.ToString(); /*if(strName =="" ) } in class SchduleContainer { ...... private string sName; public string SetScheduleName { set { //FormWizIntervalTime form = new FormWizIntervalTime(); sName = value; MessageBox.Show(sName); } get { return sName; //MessageBox.Show(sName); } } } Lastly in class FormWizConfirm { ........ private ScheduleContainer name; private void FormWizConfirmation_Load(object sender, System.EventArgs e) { //yew chong - over here, you declared another new object, therefore new memory //will be assigned again, therefore the values would not be able to be passed over. name = new ScheduleContainer(); txtCName.Text = name.SetScheduleName; // string i = "text"; //name.SetScheduleName = i; //txtCName.Text = i; MessageBox.Show(txtCName.Text); } } the problem is...when the FormWizConfirm loads, its not displaying the value set in Form A(showing a blank txtfield). there are 2 more forms between FormWizIntervalTime and FormWizConfirm. thanks in advance!

Answers (1)