Solved

Visual Studio 2010 - Looking for a margin inside Textbox

Posted on 2012-03-14
2
2,828 Views
Last Modified: 2012-03-15
I've got a form with a textbox in it and the text butts right up against the border. It looks very unprofessional but I can't figure out a way to add padding on the left or right.

Screenshot. Note the text right up against the border.
I see the Margin property, but I've tried changing it from the default of 3 all the way up to 25 with no affect. But, the HELP seems to suggest Margin is space BETWEEN controls, not for the text within it.

The textbox is docked, but that shouldn't matter.

How can I show a little space on the left and right?
0
Comment
Question by:Kaprice
2 Comments
 
LVL 3

Accepted Solution

by:
zofcentr earned 500 total points
ID: 37723808
There is property like padding for controls which sets this what you want.
Unfortunately for textbox like controls it is not used by Winforms framework.
Details here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.padding.aspx

There is probably more then one workarounds like below one.

Create panel with border and color like your Textbox.
Set padding of this panel and insert textbox into the panel
Set textbox border to none.

Hope this will help
0
 

Author Closing Comment

by:Kaprice
ID: 37723984
I'm shocked and disappointed that MS neglected the very obvious and valuable property of text margin for textboxes.

But, you've provided a very easy workaround. Thank you!
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question