how to access to Control's Property from other forms ?
C#
4
Posts
3
Posters
0
Views
1
Watching
-
Form2 needs access to textBox1. There are various ways you can accomplish this. One might be...
public class Form2 : Form { private TextBox _textBox; public TextBox RemoteTextBox { get{ _textBox = value; } } // ... } form2.RemoteTextBox = form1.textBox1;
-
Form2 needs access to textBox1. There are various ways you can accomplish this. One might be...
public class Form2 : Form { private TextBox _textBox; public TextBox RemoteTextBox { get{ _textBox = value; } } // ... } form2.RemoteTextBox = form1.textBox1;
-
This is actually bad OOP practice. Form2 would be forever linked and totally dependant on the existance of Form1. Form2 should never care about Form1 at all. Each form is responsible for the manipulation of the controls on it, not other forms. If you need to do something on Form1, expose an event on Form2 that Form1 subscribes to. This way, other forms can subscribe to that event and do whatever they need to do in response to that event. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome