Firstly, they aren't the same class: one is Form1, and the other is Program
Secondly, the control is (by default) private. And rightly so. You could
make this "internal" or "public", but I wouldn't recommed it. Better to
expose this via a custom property on Form1:
public string RichText {
set { richTextBox1.Text = value; }
get { return richTextBox1.Text; }
}
Thirdly, in C# (and .Net generally) there is no automatic default instance
of (for instance) a form, so you need to work with an instantiated instance
of the form - something like (in Program.cs)
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
using (Form1 formInstance = new Form1()) {
formInstance.RichText = "Test 1.1";
Application.Run(formInstance);
}
}
Would you be moving over from VB6 by any chance? I guess this from the
Form1.richTextBox1 line.
The code above works fine for me.
Marc
"Christopher" <Ch*********@discussions.microsoft.com> wrote in message
news:C8**********************************@microsof t.com...
Cant access a object that is in the same class it seems...
With a new c# win. app. project in vis studio 2k5, if I want to access a
richTextBox that was defined in Form1.Designer.cs. (richTextBox1).
I write a simple line in program.cs
richTextBox1.Text="Test 1.1";
Essentially richTextBox1 is unknown to program.cs ?
so I figured there was a proper name to this textbox
Form1.richTextBox1 ?
So my question is how to access objects from the partial class Form1 ?