Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Disable typing in combobox

Managed C++ combobox

  • Please log in to reply
5 replies to this topic

#1 Crane

Crane

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 388 posts

Posted 13 July 2006 - 03:35 PM

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?
  • 0

#2 Lop

Lop

    Speaks fluent binary

  • Just Joined
  • PipPipPipPipPipPipPip
  • 1112 posts

Posted 14 July 2006 - 06:17 AM

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;
		 }

  • 0

#3 Crane

Crane

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 388 posts

Posted 14 July 2006 - 07:47 AM

Thanks lop, works perfect
  • 0

#4 Lop

Lop

    Speaks fluent binary

  • Just Joined
  • PipPipPipPipPipPipPip
  • 1112 posts

Posted 15 July 2006 - 07:28 AM

No problem!
  • 0

#5 SpaceGhost

SpaceGhost

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 23 September 2008 - 02:49 PM

You have to do this:

myComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
  • 0

#6 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 24 April 2012 - 07:17 PM

As answered by SpaceGhost, the best way to do this is
myComboBox.DropDownStyle = ComboBoxStyle.DropDownList;

  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download