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}
这篇关于文本框填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:文本框填充
基础教程推荐
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
