积极答复者
winform 自定义textbox,文字的四周间距问题

问题
答案
-
可能要变通一下实现,将TextBox放到Panel中实现
http://stackoverflow.com/questions/4903083/textbox-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:
- Create a Panel
- Set its border to match a Textbox (e.g., Fixed3D)
- Set its background color to match a Textbox (e.g., White or Window)
- Set its padding to your satisfaction (e.g., 10,3,10,3)
- Add a Textbox inside the panel
- Set the Textbox's border to none
- 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.
专注于.NET ERP/CRM开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms
- 已建议为答案 Hart WangModerator 2016年9月1日 2:21
- 已标记为答案 风疯枫林剑客 2016年9月6日 0:53
全部回复
-
你是否可以截图,具体告知你希望的情况是什么?
ASP.NET Forum
StackOverFlow
FreeRice Donate
Issues to report
Free Tech Books Search and Download -
可能要变通一下实现,将TextBox放到Panel中实现
http://stackoverflow.com/questions/4903083/textbox-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:
- Create a Panel
- Set its border to match a Textbox (e.g., Fixed3D)
- Set its background color to match a Textbox (e.g., White or Window)
- Set its padding to your satisfaction (e.g., 10,3,10,3)
- Add a Textbox inside the panel
- Set the Textbox's border to none
- 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.
专注于.NET ERP/CRM开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms
- 已建议为答案 Hart WangModerator 2016年9月1日 2:21
- 已标记为答案 风疯枫林剑客 2016年9月6日 0:53