using richtextbox control programatically i'm appending text to the richtextbox .
richTextBox1.AppendText("hello");
somehow the text appears in the richTextBox1.Text but is not shown in the form.
any idea of what might be the problem?
(I checked the forecolor seems ok).
Thanks in advance
Edit:
found the root cause (had by mistake the initializeComponent() twice. )
private void InitializeComponent()
{
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(114, 104);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(100, 96);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.richTextBox1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
public Form1()
{
InitializeComponent();
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
richTextBox1.AppendText("hello world");
}`
but still curious about why did this cause this weird behavior?