R
R
random2014-10-12 22:08:18
C++ / C#
random, 2014-10-12 22:08:18

How to establish communication between Forms?

private void button2_Click(object sender, EventArgs e)
{
Close();
Form1.textBox1.Text = "";
Form1.textBox2.Text = "";
Form1.textBox3.Text = "";
}
From Form2 I can't access textBox1 from Form1, writes "inaccessible due to its protection level".
I can't find a solution at all.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AlexP11223, 2014-10-12
@demon123

The controls in the designer have a Modifiers property, you can set it to public if you really need to.
But most likely you are doing something strange and wrong. Read better about OOP, encapsulation and all that.
And give the controls normal names, not textbox999 and button85.

A
Alexander Taratin, 2014-10-12
@Taraflex

Describe for Form1 public setters for required Form1.textBox.Text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question