Textbox padding(文本框填充)
问题描述
我在互联网上搜索过,我一定是使用了错误的关键字,因为我找不到任何东西.我想创建一个文本框,其中的文本从离左侧稍远的地方开始.
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:
- 创建面板
- 设置其边框以匹配文本框(例如,Fixed3D)
- 设置其背景颜色以匹配文本框(例如,白色或窗口)
- 将其填充设置为您满意的值(例如,10,3,10,3)
- 在面板内添加一个文本框
- 将文本框的边框设置为无
- 使用文本框的 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}
这篇关于文本框填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:文本框填充


基础教程推荐
- 全局 ASAX - 获取服务器名称 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01