为什么焦点矩形不显示,直到Tab键pressed? [英] Why is Focus Rectangle not shown until Tab key pressed?
问题描述
我有一个奇怪的问题(可能只有理解了),为什么在测试应用程序中的焦点矩形不显示,直到我preSS Tab键。
我要显示一个对话框,有两个radioboxes和两个按钮。当我显示的对话框中,我倒要看看在我第一次单选按钮的焦点正确。 (这样用户能看到的重点是)。我下令控制和tabIndex属性设置为0至4,使它们在正确的顺序。 (radiobox 1具有的tabIndex 0,...)
当我显示对话框第一radiobox具有焦点,但它没有围绕它的焦点正确。 (直到我preSS TAB键。)
我创建了一个完全空的WinForms项目(Visual Studio 2010中),增加了控制和启动它。因此,有没有什么特别的。
有人可以给我一个提示,我在做什么错了?
对不起,这里是我的样本的code:
公共类Form1中
私人小组的button1_Click(发件人为System.Object的,_
Ë作为System.EventArgs)_
手柄Button1.Click
Me.Close()
结束小组
私人小组Button2_Click(发件人为System.Object的,_
Ë作为System.EventArgs)_
手柄Button2.Click
Me.Close()
结束小组
私人小组Form1_Shown(发件人为对象,_
Ë作为System.EventArgs)_
手柄Me.Shown
RadioButton1.Focus()
RadioButton1.Select()
SendKeys.SendWait({TAB})
SendKeys.SendWait(+ {TAB})
结束小组
末级
在我评论的,这的确是一个用户preference设置。
但显示矩形,尽量继承自己的单选按钮,并覆盖 ShowFocusCues
功能:
公共类RadioWithFocus
继承单选按钮
受保护的覆盖只读的属性ShowFocusCues()作为布尔
得到
返回TRUE
最终获取
高端物业
末级
I have a weird problem (probably only to understand) why in a test app the focus rect is not shown until i press the tab key.
I want to show a dialog with two radioboxes and two buttons. When i display the dialog, i'd like to see a focus rect around my first radiobutton. (So that the user can see where the focus is.) I ordered the controls and set the tabindex property from 0 to 4 so that they are in the correct order. (radiobox 1 has tabindex 0, ...)
When i show the dialog the first radiobox has the focus, but it has no focus rect around it. (Until i press tab key.)
I created an completely empty winforms project (Visual Studio 2010), added the controls and started it. So there is nothing special at all.
Can someone give me a hint what i am doing wrong?
Sorry, here is the code of my sample:
Public Class Form1
Private Sub Button1_Click(sender As System.Object, _
e As System.EventArgs) _
Handles Button1.Click
Me.Close()
End Sub
Private Sub Button2_Click(sender As System.Object, _
e As System.EventArgs) _
Handles Button2.Click
Me.Close()
End Sub
Private Sub Form1_Shown(sender As Object, _
e As System.EventArgs) _
Handles Me.Shown
RadioButton1.Focus()
RadioButton1.Select()
SendKeys.SendWait("{TAB}")
SendKeys.SendWait("+{TAB}")
End Sub
End Class
As I commented, this is really a user preference setting.
But to show the rectangle, try inheriting your own RadioButton and override the ShowFocusCues
function:
Public Class RadioWithFocus
Inherits RadioButton
Protected Overrides ReadOnly Property ShowFocusCues() As Boolean
Get
Return True
End Get
End Property
End Class
这篇关于为什么焦点矩形不显示,直到Tab键pressed?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!