passing vlaue from 1 form to another
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)
1
I don't know how you are doing it so I don't know if there is an easier way. My guess is that there is not an easier way.
Note that often the "secret" to making a program that is easy to use is complex development. In other words, sometimes we must write complicated program to make one that is easy to use. Windows and .Net and database software such as SQL Server does a lot for us, but sometimes we must do some programming outselves.
My guess is that the code necessary for the search page is not difficult except for many details that need to be done.
Probably what I would do is to create a List<String> for each filter (selection criteria) then concatenate them all together as needed.
0
Ya code is not difficult.
Thanks for your reply.