Question

i am using vb.net to edit a gridview value and when shift is pressed i want to edit multiple cellvalues that belong to a group in the same time, now my problem is when shift is pressed and i click a number key it will give me a symbole

for example

  SHIFT+1 = !
  SHIFT+2 = @
  and so on

However i want it to be

SHIFT+1 = 1
SHIFT+2 = 2
and so on

is there a built in functionality to do this?

if not, then i think i need to write a function to do this which functions as when shift+1 is pressed then keyboard inpt is 1 and not !

any ideas on how achive such behavior in vb.net? and don't tell me to use ctrl because i am using it for another thing already and it won't type when using ctrl :D

Was it helpful?

Solution

You can use a naive routine such as this. If you need comma etc, modify as needed:

Private Sub TextBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
    If e.Shift AndAlso
       (Keys.KeyCode And e.KeyData) >= Keys.D1 AndAlso
       (Keys.KeyCode And e.KeyData) <= Keys.D9 Then

        TextBox1.SelectedText = ChrW((Keys.KeyCode And e.KeyData))
        e.SuppressKeyPress = True

    End If
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top