i'm tyring to create a custom textbox class, but there is no UI

A

Antuane

i'm trying to create a custom textbox class, by simply creating a new class
& inheriting from the textbox class.
But i don't have a UI of this class.
I.e., how can i set up the default text, color for this text box - via the
properties window if there is no UI.
Currently i'm doing this via code & this is a headache, cuz i've got to drop
this control onto a form & then check out whether my UI changes are as
required.

Is there a way for me to see this custom class UI while in design mode.

Just as i creat a custom Form, i can inherit from a existing windows form &
see the UI....
 
G

Guest

You are on the right track. The UI is available through the instantiated
version, when you inherit directly from a control. Create your inherited
class in a separate control library, which compiles to a dll. From the
Toolbox, you can add the dll, which will be in the bin folder of the project.
The control library should show its controls as checked, as you add it in.
Remember to set a reference to your controls library inside your exe project.

You can override OnCreateControl, in your inherited control. It acts like a
Load event. You can prompt a read of default properties there.

Protected Overrides Sub OnCreateControl()
MyBase.Text = Me.Text
MyBase.OnCreateControl()
End Sub

You can set default properties as follows.

Private _Text As String = "New Text"
Public Shadows Property Text() As String
Get
Return Me._Text
End Get
Set(ByVal Value As String)
Me._Text = Value
End Set
End Property

When you instantiate the control on a form from the Toolbox, the properties
will be available just as they would for a standard Textbox.

www.charlesfarriersoftware.com
 
G

Guest

Also, remember to add your controls project to the solution. You can create
it as a new project under the solution.
 
H

Herfried K. Wagner [MVP]

Antuane said:
i'm trying to create a custom textbox class, by simply creating a new
class
& inheriting from the textbox class.
But i don't have a UI of this class.
I.e., how can i set up the default text, color for this text box - via the
properties window if there is no UI.
Currently i'm doing this via code & this is a headache, cuz i've got to
drop
this control onto a form & then check out whether my UI changes are as
required.

Is there a way for me to see this custom class UI while in design mode.

You mean a graphical editor like for usercontrols and forms? No, that's not
possible for controls that are no forms or usercontrols. You'll have to set
the properties through code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top