radix3 wrote:
private void button1_Click(object sender, EventArgs e) { Form2 obj = new Form2(); obj.Show(); }
Because obj is not a member variable, you have thrown away your reference to this form, meaning you cannot access it's member variables. You've also not set the parent of this form, which has implications for your UI, and how form2 can access form1.
radix3 wrote:
private void button1_Click(object sender, EventArgs e) { Form1 obj = new Form1(); bool b = textBox1.Text.Equals(obj.richTextBox1.Text);
You're obviously self taught. That's fine, so am I, but I learned by buying a lot of books and reading them. You obviously don't know the first thing about how object oriented code works, and you desperately need to learn.
obj in this code is a NEW form1, it has NOTHING to do with the Form1 instance that is already visible. In the first instance, as I say, you need to learn some programming basics. As to your specific issue, I'd set up a delegate between the two forms for communication. I'd also NEVER make a control on a form public, I may make a property that returns the text on the richtextbox ( but does not allow setting it unless necessary ). This is, again, something you will understand when you know some basics about OO.