带边框底部的文本框仅在Widnows表单中 [英] TextBox with border bottom only in Widnows Forms
本文介绍了带边框底部的文本框仅在Widnows表单中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个文本框,其底边框需要为两个像素,并且颜色为蓝色?
I need a textbox whose bottom border needs to be two pixel and color blue? How to do it?
推荐答案
通过在派生类中重写方法OnPaint
.如果需要更多空间用于此声明,则还需要使用y覆盖方法SetClientSizeCore
来调整客户端大小.
请参阅:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onpaint.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.setclientsizecore.aspx [ ^ ].
除了覆盖方法OnPaint
,您还可以处理事件Paint
,但是如果仍然必须创建派生类,则没有太大意义:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.paint.aspx [ ^ ].
渲染时,不要重复常见的错误:不要创建类System.Drawing.Graphics
的实例,而是使用事件参数parameter中传递的实例.
—SA
By overriding of the methodOnPaint
in the derived class. If you need more room for this declaration, you would also need to adjust the client size using y overriding the methodSetClientSizeCore
.
Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onpaint.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.setclientsizecore.aspx[^].
Instead of overriding of the methodOnPaint
you can also handle the eventPaint
, but it makes not much sense if you have to create a derived class anyway:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.paint.aspx[^].
When rendering, don''t repeat a common mistake: don''t create an instance of the classSystem.Drawing.Graphics
, instead, use the one passed in the event argument parameter.
—SA
这篇关于带边框底部的文本框仅在Widnows表单中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文