C# : ComboBox AutoComplete

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • igalep132
    New Member
    • Dec 2007
    • 8

    C# : ComboBox AutoComplete

    Hey,

    I've a comboBox with some List Items (countries names)
    I was wondering how can I force the user to select those countries which are Listed in the collection list only, without any opportunity to add his own item

    10X
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Change the combobox style to that of only allows what is in it. It's an option on the property page.

    Comment

    • igalep132
      New Member
      • Dec 2007
      • 8

      #3
      Originally posted by Plater
      Change the combobox style to that of only allows what is in it. It's an option on the property page.
      tanx for quick answer,
      which property is it ?
      I've tried all properties which consider Item/Collection but non of the is suitable

      10X again

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        It's not what you would think :-D
        The property is called 'DropDownStyle'
        Changing the value to 'DropDownList' will limit the control to what is in it's list (Making it behave like a listbox).

        If you don't want to dissallow like that, there is also a method of checking to see if the selected index is not -1.
        If you populate the combobox with values and have the auto-complete on, if someone types in something not in the list, the selected index will be -1, if they typed in something that IS in the list, the combo box automatically moves to select it and the selectedindex will have a >-1 value

        Comment

        • dzenanz
          New Member
          • Feb 2008
          • 45

          #5
          DropDownStyle has to be DropDownList

          Comment

          • SPrerna
            New Member
            • Oct 2012
            • 2

            #6
            Hello Plater ,

            Thank you so much for the solution..i was trapped into this problem. I am new for asp.net.Once again thanx .

            Comment

            Working...