文字框填充 [英] Textbox padding

查看:87
本文介绍了文字框填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在互联网上搜索过,因为找不到任何东西,所以一定使用了错误的关键字.我想创建一个文本框,该文本框的文本从左到左稍有一段距离.

就是这样.

解决方案

正如您最可能发现的那样,Winforms文本框没有填充属性.由于面板确实公开了Padding属性,因此一种方法是:

  1. 创建面板
  2. 设置其边框以匹配文本框(例如Fixed3D)
  3. 设置其背景颜色以匹配文本框(例如,白色或窗口)
  4. 将其填充设置为您满意的水平(例如10,3,10,3)
  5. 在面板内添加文本框
  6. 将文本框"的边框设置为无"
  7. 使用文本框的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:

  1. Create a Panel
  2. Set its border to match a Textbox (e.g., Fixed3D)
  3. Set its background color to match a Textbox (e.g., White or Window)
  4. Set its padding to your satisfaction (e.g., 10,3,10,3)
  5. Add a Textbox inside the panel
  6. Set the Textbox's border to none
  7. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆