当用户点击一个键入Rtextbox
的字母时,我有一个带字母表所有字母按钮的电路板。用户也可以使用键盘,然后触发btn_click event
。但是,当他们使用键盘时,文本会出现不同的字体和大小,导致文本框闪烁
如何将字体设置为与单击按钮时相同?
谢谢!
Private Sub btnA_mouseclick(sender As System.Object, e As System.EventArgs) Handles btnA.Click, btnB.Click, btnC.Click, btnD.Click, btnE.Click, btnF.Click, btnG.Click, btnH.Click, btnI.Click, btnJ.Click, btnK.Click, btnL.Click, btnM.Click, btnN.Click, btnO.Click, btnP.Click, btnQ.Click, btnR.Click, btnS.Click, btnT.Click, btnU.Click, btnV.Click, btnW.Click, btnX.Click, btnY.Click, btnZ.Click
Dim btn As Button = DirectCast(sender, Button)
Dim btnText As String = btn.Text
Dim holdCursorPos As Integer = RTextBox.SelectionStart
RTextBox.SelectedText = btnText
RTextBox.SelectionStart = holdCursorPos + 1
end sub
Private Sub FormEnglish_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
Dim key = e.KeyChar.ToString().ToUpper()
Dim KeyClick = "btn" & key
For Each Button In Me.Controls
If Button.name = KeyClick Then btnA_mouseclick(Button, Nothing)
Next
End Sub