Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Guest mutant
Posted
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.
  • Moderators
Posted
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?)
Visit...Bassic Software
Posted

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.

  • *Experts*
Posted

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. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...