none
how to turn-off-caps-lock in textbox RRS feed

  • Question

  • hi

    how to turn-off-caps-lock in textbox  with password 

    when form open and focus textpassword

    use this code but not work

       Private Sub TEXT_EMPPASSLOG_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TEXT_EMPPASSLOG.KeyDown
            On Error Resume Next
            If e.KeyData = Keys.CapsLock Then e.SuppressKeyPress = True
        End Sub

    Wednesday, November 21, 2018 3:41 PM

Answers

  • Hi

    If you just want to limit the TextBox to lower case, then this might help. Does not alter the CAPS LOCK state.

      Private Sub TEXT_EMPPASSLOG_TextChanged(sender As Object, e As EventArgs) Handles TEXT_EMPPASSLOG.TextChanged
        Dim tb As TextBox = DirectCast(sender, TextBox)
        tb.Text = tb.Text.ToLower
      End Sub


    Regards Les, Livingston, Scotland


    • Edited by leshay Wednesday, November 21, 2018 3:53 PM
    • Marked as answer by ahmeddc Wednesday, November 21, 2018 4:10 PM
    Wednesday, November 21, 2018 3:53 PM

All replies

  • Hi

    If you just want to limit the TextBox to lower case, then this might help. Does not alter the CAPS LOCK state.

      Private Sub TEXT_EMPPASSLOG_TextChanged(sender As Object, e As EventArgs) Handles TEXT_EMPPASSLOG.TextChanged
        Dim tb As TextBox = DirectCast(sender, TextBox)
        tb.Text = tb.Text.ToLower
      End Sub


    Regards Les, Livingston, Scotland


    • Edited by leshay Wednesday, November 21, 2018 3:53 PM
    • Marked as answer by ahmeddc Wednesday, November 21, 2018 4:10 PM
    Wednesday, November 21, 2018 3:53 PM
  • Hi

    If you just want to limit the TextBox to lower case, then this might help. Does not alter the CAPS LOCK state.

      Private Sub TEXT_EMPPASSLOG_TextChanged(sender As Object, e As EventArgs) Handles TEXT_EMPPASSLOG.TextChanged
        Dim tb As TextBox = DirectCast(sender, TextBox)
        tb.Text = tb.Text.ToLower
      End Sub


    Regards Les, Livingston, Scotland


    THANKS
    Wednesday, November 21, 2018 4:10 PM
  • Hi

    The code snippet I posted is wrong. I forgot about the cursor position within the TextBox.

    Here is an amended version.

      Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TEXT_EMPPASSLOG.TextChanged
        TEXT_EMPPASSLOG.Text = TEXT_EMPPASSLOG.Text.ToLower
        TEXT_EMPPASSLOG.SelectionStart = TEXT_EMPPASSLOG.Text.Length
        TEXT_EMPPASSLOG.SelectionLength = 0
      End Sub


    Regards Les, Livingston, Scotland


    • Edited by leshay Wednesday, November 21, 2018 9:36 PM Changed ToUpper to ToLower
    Wednesday, November 21, 2018 4:22 PM
  • Hi

    The code snippet I posted is wrong. I forgot about the cursor position within the TextBox.

    Here is an amended version.

      Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TEXT_EMPPASSLOG.TextChanged
        TEXT_EMPPASSLOG.Text = TEXT_EMPPASSLOG.Text.ToUpper
        TEXT_EMPPASSLOG.SelectionStart = TEXT_EMPPASSLOG.Text.Length
        TEXT_EMPPASSLOG.SelectionLength = 0
      End Sub


    Regards Les, Livingston, Scotland

    All you wish is idea only THANKS
    Wednesday, November 21, 2018 4:36 PM