Windows Develop Bookmark and Share   
 index > Windows Forms General > Default padding of TextBox control
 

Default padding of TextBox control

Is it possible to change the default padding (internal spacing, in pixels) of the contents of a TextBox control? I want some space (internal margins) around my text in the TextBox. The MSDN library says that this is a Protected Overridable ReadOnly Property.

Moonshadow  Thursday, June 22, 2006 8:49 PM
I doubt it, the Windows control doesn't support it. The property is new for .NET 2.0 and documented everywhere as "...not intended to be used directly from your code. This property is not relevant for this class". Sounds like they have plans for .NET 3.0, WinFX, Avalon...

nobugz  Thursday, June 22, 2006 9:05 PM
I doubt it, the Windows control doesn't support it. The property is new for .NET 2.0 and documented everywhere as "...not intended to be used directly from your code. This property is not relevant for this class". Sounds like they have plans for .NET 3.0, WinFX, Avalon...

nobugz  Thursday, June 22, 2006 9:05 PM
Hi nobugz. That's what I figured. Being a Newbie to VB I thought it best to ask anyway. My crude workaround is to put a slightly larger white panel behind the testbox which gives the illusion of margins.
Moonshadow  Thursday, June 22, 2006 11:18 PM
it should be possible with pinvoke
joeycalisay  Friday, June 23, 2006 10:02 AM
I am not familiar with pinvoke. Care to elaborate on how it couldbe applied in this situation?
Moonshadow  Friday, June 23, 2006 10:21 AM

Moonshadow wrote:
I am not familiar with pinvoke. Care to elaborate on how it couldbe applied in this situation?

windows forms of .net is just a wrapper around win32 api of windows. .NET provides virtual members from the Control base class to interact witn this api, createparams and wndproc are some. you can try overriding createparams to customize the border of a textbox subclass (see george sheperd's faq here for reference) if i understood your question.

joeycalisay  Sunday, June 25, 2006 12:43 PM
Joey: Thanks for the explanation. I understand the basic concept of what you are saying - appying it at my skill level is achallenge. I have been studying the example that you linked to and will see if I can figure a way to use this approachin my application.
Moonshadow  Sunday, June 25, 2006 2:37 PM

You can use google to search for other answers

Custom Search

More Threads

• How can I make an image on a Picture control transparent
• How to run a windows form seperate from DoWork thread while its rendering a graph
• Different color for each listbox (or CB) item
• Problem Painting Custom Tab Control
• Please help me with showcheckbox in DateTimePicker problem.
• Question about opening a USB device handle
• Constantly active text box and key press??
• how does attachdbfilename work??
• NumericUpDown : How to disable autocorrect when the user enters an invalid number
• checking primary key @ user input