VB.NET中Winforms按钮周围的虚线矩形 [英] dashed rectangle around a winforms button in VB.NET
本文介绍了VB.NET中Winforms按钮周围的虚线矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Iam在这个问题上停留了相当长的时间.我在vb.net winform中有一个按钮控件.我想将焦点设置在使用了btnSave.Select()的按钮上,但是此函数将焦点设置在按钮上,而不在按钮周围显示虚线矩形.如何以编程方式在按钮控件周围创建虚线矩形?请帮忙.真的很紧急!
谢谢与问候,
Girish
Iam stuck with this issue for quite some time. I have a button control in a vb.net winform. I want to set focus on this button for which i have used the btnSave.Select(), but this function sets the focus on the button without displaying the dashed rectangle around the button. How can i create dashed rectangle around a button control programatically? Please help. This is really urgent!
Thanks & Regards,
Girish
推荐答案
尝试使用btnSave.Focus()
代替btnSave.Select()
如果不起作用,请查看此链接
按钮控制
问候
Ankit
Hi,
TrybtnSave.Focus()
instead ofbtnSave.Select()
If it doesn''t work please have a look on this link
Button Control
Regards
Ankit
尝试btnSave.Focus()
.
它不是Select
,它是Focus
.
例如,在自定义控件类中自定义绘制Button时,只需要绘制一个虚线矩形即可.
您可以使用的一种课程是System.Windows.Forms.ButtonRenderer
.此类是已渲染的,它只是使用Graphics实例进行绘制,但是它一次渲染了整个按钮,而不是单独的元素.
如果要使用单独的元素,请使用System.Windows.Forms.ControlPaint
.您可能要对虚线矩形使用System.Windows.Forms.ControlPaint.DrawGrid
.还有许多其他有用的方法.
—SA
It''s notSelect
, it''sFocus
.
You only need to draw a dashed rectangle if you custom-draw your Button, for example, in your custom control class.
One class you can use isSystem.Windows.Forms.ButtonRenderer
. This class is the rendered, it just draw using the Graphics instance, but it renders the whole button at once, not its separate elements.
If you want a separate elements, useSystem.Windows.Forms.ControlPaint
. You may want to useSystem.Windows.Forms.ControlPaint.DrawGrid
for your dotted rectangle. There are many other useful methods.
—SA
这篇关于VB.NET中Winforms按钮周围的虚线矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文