用VB.NET 做一个触摸屏里面的数字键盘?
用VB.NET 做一个触摸屏里面的数字键盘:
在form1 里面有好多textbox,当我点击任意一个textbox时,这个小键盘就会弹出,
键盘上面有0-9数字,还左、右移,回车,删除,点,空格 ,上面有一个textbox,
用来点击数字时,通过这个textbox 传到form1里面的当前输入textbox里面,谁会
求高手帮助,多谢!
[解决办法]
哥哥,做一个窗口不就好了吗?这个是什么意思?
[解决办法]
'剩余的自己去完善吧
Public Class Form2
Private btn As ButtonDef
Private btnText = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
".", "Del", "Left", "Right", "Enter", "Space"}
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 0 To 15
Dim x = If((i + 1) Mod 3 = 0, 3, (i + 1) Mod 3)
Dim y = If((i + 1) Mod 3 = 0, (i + 1) \ 3 - 1, (i + 1) \ 3)
btn(i) = New Button With
{
.Name = "btn_" & i.ToString(0),
.Text = btnText(i),
.Location = New Point(x * 48 - 46, y * 26 + 2),
.Size = New Size(If(.Text <> "Space", 46, 48 * 3 - 2), 24)
}
AddHandler btn(i).Click, AddressOf btn_Click
Me.Controls.Add(btn(i))
Next
End Sub
Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
With btn
Form1.Activate()
Select Case TryCast(sender, Button).Name
Case .Num0.Name, .Num1.Name, .Num2.Name, .Num3.Name, .Num4.Name,
.Num5.Name, .Num6.Name, .Num7.Name, .Num8.Name, .Num9.Name, .Dot.Name
SendKeys.Send(TryCast(sender, Button).Text)
Case .Left.Name, .Right.Name, .Del.Name, .Enter.Name
SendKeys.Send("{" & TryCast(sender, Button).Text & "}")
Case .Space.Name
SendKeys.Send(" ")
Case Else
End Select
End With
End Sub
End Class
Public Structure ButtonDef
Default Public Property Index(ByVal idx As Integer) As Button
Get
Select Case idx
Case 0 : Return Num0
Case 1 : Return Num1
Case 2 : Return Num2
Case 3 : Return Num3
Case 4 : Return Num4
Case 5 : Return Num5
Case 6 : Return Num6
Case 7 : Return Num7
Case 8 : Return Num8
Case 9 : Return Num9
Case 10 : Return Dot
Case 11 : Return Del
Case 12 : Return Left
Case 13 : Return Right
Case 14 : Return Enter
Case 15 : Return Space
Case Else : Return Nothing
End Select
End Get
Set(ByVal value As Button)
Select Case idx
Case 0 : Num0 = value
Case 1 : Num1 = value
Case 2 : Num2 = value
Case 3 : Num3 = value
Case 4 : Num4 = value
Case 5 : Num5 = value
Case 6 : Num6 = value
Case 7 : Num7 = value
Case 8 : Num8 = value
Case 9 : Num9 = value
Case 10 : Dot = value
Case 11 : Del = value
Case 12 : Left = value
Case 13 : Right = value
Case 14 : Enter = value
Case 15 : Space = value
End Select
End Set
End Property
Public Num0, Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8, Num9 As Button
Public Left, Right, Enter, Space, Dot, Del As Button
End Structure