combobox c# text add ... simple question RRS feed

  • Question

  • combobox c# text add ... simple question


    Desired Experience

    >>Combobox adds typed in strings to its item collection when the user presses enter .. without me writing new software

    Actual Experience

    >>I wrote a few lines of software to add above feature.


    The software I wrote is small but I do not want to use extra software if the feature is built in.  Here is the little successful software I wrote .. I just dont know if it is necesary.


    private void

    comboBox1_KeyPress(object sender, KeyPressEventArgs e)


       if (e.KeyChar == (char)Keys.Return)








    All related questions below.

    1. Will a combobox add an edited TEXT string automatically to its items members?

    2. Must I write software to do the above?

    3. Is there a boolean value I must set so that the combobox automatically adds items?

    Thanks in advance.


    Sunday, July 15, 2007 5:41 PM


All replies

  • #1: No
    #2: Yes
    #3: see #1.
    Sunday, July 15, 2007 7:52 PM
  • Thank You

    Primary question is answered.


    I was about to apologize for my intentional redundancy in the question.

    The redundancy was there for emphasis and to initiate threads of thought.


    I like your indirection in answer 3. 

    Who gets to mark  a response as an answer? (I did not do it)


    I suppose the logic is that

    a point of customization is provided ...

    and  any <OBJECT> can be placed the combobox not just strings.


    Any further comments?


    Friday, July 20, 2007 2:15 PM
  • MSFT employees mark an answer when they judge the post to be accurate.  Just unmark it if you disagree.  Event handlers are there to give controls custom behavior, just like you did.  Ask a question if you want a comment.
    Friday, July 20, 2007 2:31 PM