Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Question
 

Question

Hello:
I am new to .NET and I am trying to create a simple application where i developed a control that allows you to draw different drawings. The control is derived from Control base class and I am doing my own painting logic.
I have provided a context menu from which user can select the type of drawing like Rectangle Ellipse etc.
I was planning to add a new feature where I want to allow user to type some text.
So I added one more menu item to context menu called text... On click of that menu I wanted to display a textbox at the point of click. I tried to display the textbox onPaint but for some reason I don't see the text box at all. Am I missing something?

Here is my on paint.

onPaint(...)
{
...
if ( bShowTextBox)
{
if ( this.textBox1 == null )
 this.textBox1 = new System.Windows.Forms.TextBox();
 
this.textBox1.Location = ptTextBoxLocation;
this.textBox1.Size = new Size (300,100);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 0;
this.textBox1.Text = "";
this.textBox1.BringToFront ();
this.textBox1.Visible= true;
}
}
MigrationUser 1  Tuesday, January 06, 2004 9:11 PM
I think you need to add the textbox to you custom control's Controls collection after you've created it. I.e. this.Controls.Add(this.textBox1);
MigrationUser 1  Wednesday, January 07, 2004 8:27 AM

You can use google to search for other answers

Custom Search

More Threads

• Control Borders
• Raising events in inheritance forms
• ToolStrip focus issue
• Embedd froms and design-time issues
• AutoScaleMode and development on different machines
• Copy DataSet Component DesignTime Behavior?
• Creating controls at design time: Error: 'child' is not a child control of this parent
• Change backcolor and forecolor when hovering menu items
• ComboBox.SelectedIndexChanged event
• A few questions on textbox validation