I'd like to add a text control via Controls.Add(Control) to the top of an existing control in a derived class.
However, when I try to add the new class, I get:
An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll
Additional information: ArgumentException
Any ideas Perhaps this isn't possible
Code looks like:
// // textBox1 //textBox1 =
new TextBox(); this.textBox1.Location = new System.Drawing.Point(0, 0); this.textBox1.Size = new System.Drawing.Size(0, 20); this.textBox1.Text = ""; this.Controls.Add(this.textBox1);
Adding controls to controls... Is this possible in an inherited class...
sjnaughton
Thanks, gave that a try, but... it still threw the exception. I tried:
this.textBox1.Location = new System.Drawing.Point(10, 10); this.textBox1.Size = new System.Drawing.Size(50, 20); this.textBox1.Text = "";Controls.Add(
this.textBox1);Correct me if I'm wrong, but I should be able to add a control to a control
Thanks!
Ameabaspy
sharpej
Try to have a non zero width for your textbox:
this.textBox1.Size = new System.Drawing.Size(50, 20);
Mr. Lane
Parent.Controls.Add(this.textBox1);