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}
这篇关于文本框填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:文本框填充
基础教程推荐
- 如果条件可以为空 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 将数据集转换为列表 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
