Textbox with title (VB)

cxnoel

Newcomer
Joined
Apr 6, 2003
Messages
2
Textbox with title

I want to create a TextBox which will include a title within the box instead of using a label outside the box. It will look like this:

+----------------------------------+
+Title: Normal texbox's text +
+----------------------------------+

It has to keep all existing textbox functionality, including multiline property. When the user type some text (or text added programmatically), it should appear after the title. If we erase some text or clear the box, the title should remain.

I know I will have to override the OnPaint method and use graphics functions but I am a bit confused. Does anyone has any clue to help me? I will use 3 properties for the title: TitleText, TitleColor and TitleBkgColor.

Thanks a lot.

Claude
 
Just create your own control, with a textbox and a label next to it. Then you can make those properties, and change the text, color of label, with them.
 
Do you want the title to be inside the textbox or outside as if it was a label attached to the textbox. (The same way that MS Access handles it when you paint a textbox on a form?)
 
I want the title to be inside the textbox and the text the user may enter should start after the title's text. If he deletes the text, it should not affect the title.

This is to prevent loss of space like the label does. If I put a label above the text box, I loose space to its right. If I put a label before the textbox, I loose space under the textbox (in the case of a multiline textbox). This is why I want to be able to place some multiline textboxex on a form, all having about the same size, with their title inside them.

As a bonus, if the title's properties can include forecolor and backcolor to make them more appealing, it would be appreciated.

Thanks to all suggestions.
 
If you put a Textbox and a label inside a panel control, and make all
the back colors all white (and take away the textbox border), you
can make it LOOK like the title is in the textbox. You can stick it in
a UserControl, and add any of the default TextBox features you want
into it. Just be creative. :)
 
Back
Top