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

[966 byte] By [codefund.com] at [2008-2-14]
# 1
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

codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms Designer...