dcsimg
Results 1 to 3 of 3

Thread: [RESOLVED] Insert symbol in a combobox using combination of keys

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2012
    Posts
    214

    Resolved [RESOLVED] Insert symbol in a combobox using combination of keys

    Hello,

    I am trying to type something in a combobox and when I press for example ALT+a I would like a symbol like "" to be inserted at cursor position.

    I tried this:

    Private Sub ComboBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown
    If e.KeyCode = Keys.Alt And e.KeyCode = 65 Then
    ComboBox1.Text = "test"
    End If
    End Sub

    but it doesn't seem to do anything.

    So, 2 questions.
    1. How can I detect the combination of keys pressed.
    2. Is there a function to detect cursor position and insert the text or do I have to create the string myself?

    Thx

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,143

    Re: Insert symbol in a combobox using combination of keys

    1. Follow the Blog link in my signature and check out my post on Keyboard Events for the answer to your question and more.

    2. Set the SelectedText property of the ComboBox, which will insert at the caret if no text is selected and replace if text is selected.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2012
    Posts
    214

    Re: Insert symbol in a combobox using combination of keys

    Great. I made it work. Thank you very much. Topic solved.
    Last edited by ovi_gm; May 14th, 2013 at 04:47 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width