Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Creating a Textbox in VS with Object Automation
 

Creating a Textbox in VS with Object Automation


I have used the sample in Microsoft Visual Studio .NET Automation Sample: Windows Forms Automation Add-in : http://msdn.microsoft.com/vstudio/downloads/samples/automation.asp 

just to create an add-in to produce a project with one specific winform, where you can create any controls. 

I can create Button or Label controls, just using: 

Dim host As IDesignerHost 
host = CType(applicationObject.ActiveWindow.Object, IDesignerHost) 
.... 
Dim control1 As IComponent 
control1 = host.CreateComponent(host.GetType("System.Windows.Forms.Label,System.Windows.Forms")) 
.... 

But If I try to create in the same way a textbox control using the corresponding Type: 

Dim control2 As IComponent 
control2 = host.CreateComponent(host.GetType("System.Windows.Forms.Textbox,System.Windows.Forms")) 
.... 

the error Object reference is the exception produced. 

Do you know where is my error? 

Thanks in advance 
 
MigrationUser 1  Thursday, February 27, 2003 4:31 AM
Sometimes you find the answer by yourself. Then you are happier.

The error was the sensitive case for the Type.

I need to use
 control2 = host.CreateComponent(host.GetType("System.Windows.Forms.TextBox,System.Windows.Forms")) 

instead 
control2 = host.CreateComponent(host.GetType("System.Windows.Forms.Textbox,System.Windows.Forms")) 

ie TextBox instead Textbox. A common error.

Sorry
MigrationUser 1  Thursday, February 27, 2003 12:35 PM

You can use google to search for other answers

Custom Search

More Threads

• Windows Form Designer bug in causing an event handler to disappear, C# example
• ListBox control in C#
• Custom editor on extender control
• more than one value in listbox
• RightToLeft support in PropertyGrid
• WSOD Issue in Designer
• PROBLEM: ParentControlDesigner.AllowSetChildIndexOnDrop internal?
• prob while deleting row from DataGrid
• Removing (Disabling) the veritical scrollbar in a listbox
• when using codeDomSerializer - how to get the object when openning the designer