文本框填充 [英] Textbox padding

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

问题描述

我在互联网上搜索过,我一定是使用了错误的关键字,因为我找不到任何东西.我想创建一个文本框,其中的文本从离左侧稍远的地方开始.

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.

就这样.

推荐答案

您很可能已经发现,Winforms 文本框没有填充属性.由于面板确实公开了 Padding 属性,因此一种技术是:

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. 创建面板
  2. 设置其边框以匹配文本框(例如,Fixed3D)
  3. 设置其背景颜色以匹配文本框(例如,白色或窗口)
  4. 将其填充设置为您满意的值(例如,10,3,10,3)
  5. 在面板内添加一个文本框
  6. 将文本框的边框设置为无
  7. 使用文本框的 Dock 和 Anchor 属性确实获得了预期的效果

这应该可以帮助您入门.您还可以创建一个执行上述相同操作的自定义控件.

This should get you started. You could also create a custom control that does the same thing as mentioned above.

如果您在 asp.net 中谈论文本框,请使用 CSS:
input[type="text"] {padding: 3px 10px}

In case you were talking about Textboxes in asp.net, just use CSS:
input[type="text"] {padding: 3px 10px}

这篇关于文本框填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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