dont know if this answers your question...
...if you need to acccess a component from another form for example, you need to pass the reference of the other form, to the form you will be calling from, and set the component as public.
Example...
I have 2 forms, form A has a textbox. FormB has button:
A -> has textbox
B -> has button.
in form B, if I press the button, I want Form A's textbox to display some text. To do this, I need to make the textbox in formA public (look in the modifiers property on the FormA designer for the textbox control). I also need to pass form A to formB so it can access it. Example:
//FormB:
private FormA theMainForm = null;
public class FormB(FormA mainForm)
{
this.theMainForm = mainForm;
}
private void button1_Click(object sender, EventArgs e)
{
this.theMainForm.theTextBox.Text = "hello!";
}
FormA:
//some method:
FormB theSecondForm = new FormB(this);
theSecondForm.Show();
does this help
in order to access one component from another, you need to pass the component appropriate to the callee so it can have a reference and access it
|