文字框填充 [英] Textbox padding
问题描述
我已经在互联网上搜索过,因为找不到任何东西,所以一定使用了错误的关键字.我想创建一个文本框,该文本框的文本从左到左稍有一段距离.
>
就是这样.
正如您最可能发现的那样,Winforms文本框没有填充属性.由于面板确实公开了Padding属性,因此一种方法是:
- 创建面板
- 设置其边框以匹配文本框(例如Fixed3D)
- 设置其背景颜色以匹配文本框(例如,白色或窗口)
- 将其填充设置为您满意的水平(例如10,3,10,3)
- 在面板内添加文本框
- 将文本框"的边框设置为无"
- 使用文本框的Dock和Anchor属性确实可以达到预期的效果
这应该可以帮助您入门.您还可以创建一个自定义控件,该控件执行与上述相同的操作.
如果您在谈论asp.net中的文本框,只需使用CSS:
input[type="text"] {padding: 3px 10px}
I've searched through the internet, I must be using the wrong keywords because I can't find anything. I want to create a textbox that has text starting from a little far from the left.
Just like that.
As you have most likely discovered, Winforms Textboxes do not have a padding property. Since Panels do expose a Padding property, one technique would be to:
- Create a Panel
- Set its border to match a Textbox (e.g., Fixed3D)
- Set its background color to match a Textbox (e.g., White or Window)
- Set its padding to your satisfaction (e.g., 10,3,10,3)
- Add a Textbox inside the panel
- Set the Textbox's border to none
- Play with the Textbox's Dock and Anchor properties do get desired effect
This should get you started. You could also create a custom control that does the same thing as mentioned above.
In case you were talking about Textboxes in asp.net, just use CSS:
input[type="text"] {padding: 3px 10px}
这篇关于文字框填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!