I want to pass some values to different forms at there button click event. plz guide me.I am using c sharp.net 2005,win forms. I want to access the value in a sql query in form
You can pass it through the constructor of the child form if the data is mandatory, or through a property if it is optional.
Try this code, you have to do something like following code : inside this event you have to pass data to other
private void button1_Click(object sender, EventArgs e)
{
Form2 secondForm = new Form2();
secondForm.YourProperty = "This is your data";
secondForm.Show();
}
In the other form you have to declare a property :
public string YourProperty { get; set; }
hope this help.
Use delegate. Thats the best way you could talk. Or as suggested, if form2 is a child of form1, then ctor argument based. If its 2 independent, then delegates.
You have several options: