该问题我也碰到了,特别麻烦。我采用的方法是直接将全角字符转化为半角字符:
Private Sub mCombobox_KeyPress(ByVal sender As GrapeCity.Win.MultiRow.ComboBoxEditingControl, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles mCombobox.KeyPress
e.KeyChar = TurnNumer(e.KeyChar)
End Sub
Public Shared Function TurnNumer(ByVal WB As String) As String
'将全角字符转换为半角字符
Const ChinaNumer As String = "1234567890. ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz?*,-"
Const EnNumer As String = "1234567890. ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz?*,-"
Dim C As Char
Dim CC As String
Dim I As Integer
For Each C In WB
I = InStr(1, ChinaNumer, C, CompareMethod.Binary)
If I <> 0 Then
CC = Mid(EnNumer, I, 1)
WB = Replace(WB, C, CC, , , CompareMethod.Binary)
End If
Next
Return WB
End Function |