Jump to content

Disable typing in a combo box

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
Chan

Chan

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 204 posts
I don't want users typing into a combo box and I'd like it if they could only select from the list I apply. I'm not sure why you can't disable this feature properly but can someone tell me how its done?

thanks

#2
brackett

brackett

    Programmer

  • Members
  • PipPipPipPip
  • 192 posts
Sounds like you just want the plain ol' ListBox. A ComboBox does have different DropDownStyles though, which you may want to look at.

#3
Frantic

Frantic

    Learning Programmer

  • Members
  • PipPipPip
  • 91 posts
Just capture the keydown event and don't let them type. Very easy. ListBox doesn't look as good as a ComboBox.

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
In your onKeyDown method use e.Handled = True

#5
Chan

Chan

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 204 posts
How do I add that method? Do I just type in KeyDown()?

#6
karthizen

karthizen

    Newbie

  • Members
  • Pip
  • 1 posts
does any one knows how to disable editing in a combo box?

#7
Sumarak

Sumarak

    Newbie

  • Members
  • Pip
  • 1 posts
this is what i use... very easy

--------------------------------------------------------------------------

Private Sub ComboBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown

e.SuppressKeyPress = True

End Sub

--------------------------------------------------------------------------
vb 08

#8
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
You don't need any code at all - just change the DropDownStyle property to DropDownList, instead of DropDown.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#9
norelad

norelad

    Newbie

  • Members
  • Pip
  • 1 posts
But if you want the user to be able to either only select from list or Delete then Dropdownlist is no good