Jump to content

Disable typing in combobox

- - - - -

  • Please log in to reply
5 replies to this topic

#1
Crane

Crane

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 398 posts
I would like to disable typing in a combobox without disabling the control. The user would still be able to use the drop-down list but would not be able to type.

How?

#2
Lop

Lop

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,172 posts
This isn't so hard. You have to capture the keypress event for that control.


private: System::Void comboBox1_KeyPress(System::Object^  sender, System::Windows::Forms::KeyPressEventArgs^  e) {

			 e->Handled = true;

		 }



#3
Crane

Crane

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 398 posts
Thanks lop, works perfect

#4
Lop

Lop

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,172 posts
No problem!

#5
SpaceGhost

SpaceGhost

    Newbie

  • Members
  • Pip
  • 1 posts
You have to do this:

myComboBox.DropDownStyle = ComboBoxStyle.DropDownList;

#6
kernelcoder

kernelcoder

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 269 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal
As answered by SpaceGhost, the best way to do this is
myComboBox.DropDownStyle = ComboBoxStyle.DropDownList;





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users