how to edit text in a combobox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Smish
    New Member
    • Jan 2007
    • 51

    how to edit text in a combobox

    hi,

    I have a combobox which has dropdown style set to "dropdownlist"( since i dont want the element getting populated in the combobox to be edited).

    Apart from populating the comboxbox from items form the file am giving an extra item "New" which should allow the user to add new element.

    but the problem which i come across is since the dropdown list dont allow th user to edit the text am not able to edit nethng.

    So could anyone tell me how to make tht particular text enable on index change

    thanx
    Last edited by Frinavale; Jan 27 '09, 05:15 PM. Reason: Moved to C# Answers from insights
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Have you tried to implemented a method to handle the SelectedIndexCh anged Event which enables the TextBox?

    Comment

    • Smish
      New Member
      • Jan 2007
      • 51

      #3
      i tried but i couldn't enable it..

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        Change the style

        If the problem is that you can't edit text while the style is DropDownList, but the text IS editable when the style is DropDown.... then change the style back to DropDown when the user selects the 'New' option.

        Code:
        ((ComboBox)sender).DropDownStyle = ComboBoxStyle.DropDown;
        Then when the focus leaves that control, change the style back to DropDownList.

        Comment

        • Smish
          New Member
          • Jan 2007
          • 51

          #5
          thanx a lot buddy ..it worked :)

          Comment

          Working...