J
JP
I'm sure this is a simple question and I'm overlooking the obvious. But, I
have two seperate classes (in seperate files) under the same namespace. I
am calling a method in one class that contains
public System.Windows.Forms.TextBox textBox1;
When I try to write to this textbox it never publishes anything. If I call
the same method from inside the same class it does. How can I publish to
this textbox from an external class. Simple example would be:
FILE: classone.cs
namespace DemoApp
{
public class classone : System.Windows.Forms.Form
{
public System.Windows.Forms.TextBox textBox1;
private System.ComponentModel.Container components = null;
public classone()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(0, 32);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBox1.Size = new System.Drawing.Size(568, 344);
this.textBox1.TabIndex = 4;
this.textBox1.Text = "textBox1";
//
// classone
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(568, 373);
this.Controls.Add(this.textBox1);
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
this.ResumeLayout(false);
}
public void addstatus(string status)
{
MessageBox.Show(status);
this.textBox1.AppendText("HI");
this.textBox1.AppendText(status + "\r\n\r\n");
}
}
}
FILE classtwo.cs
namespace WxAlert
{
public void addToreport(string rep, int debugDetail)
{
classone obj = new classone();
obj.addstatus(rep);
}
}
When calling the addToreport method, everything compiles and runs - just
nothing gets written to the textbox window. Not even the "HI" - the
information does show correctly in the MessageBox.
have two seperate classes (in seperate files) under the same namespace. I
am calling a method in one class that contains
public System.Windows.Forms.TextBox textBox1;
When I try to write to this textbox it never publishes anything. If I call
the same method from inside the same class it does. How can I publish to
this textbox from an external class. Simple example would be:
FILE: classone.cs
namespace DemoApp
{
public class classone : System.Windows.Forms.Form
{
public System.Windows.Forms.TextBox textBox1;
private System.ComponentModel.Container components = null;
public classone()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(0, 32);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBox1.Size = new System.Drawing.Size(568, 344);
this.textBox1.TabIndex = 4;
this.textBox1.Text = "textBox1";
//
// classone
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(568, 373);
this.Controls.Add(this.textBox1);
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
this.ResumeLayout(false);
}
public void addstatus(string status)
{
MessageBox.Show(status);
this.textBox1.AppendText("HI");
this.textBox1.AppendText(status + "\r\n\r\n");
}
}
}
FILE classtwo.cs
namespace WxAlert
{
public void addToreport(string rep, int debugDetail)
{
classone obj = new classone();
obj.addstatus(rep);
}
}
When calling the addToreport method, everything compiles and runs - just
nothing gets written to the textbox window. Not even the "HI" - the
information does show correctly in the MessageBox.