Cannot Insert or Add a String To a ComboBox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Tyce

    Cannot Insert or Add a String To a ComboBox

    When a button is clicked, a date is inserted or added into a combo box like this : ComboBox.Items. Add(string) or ComboBox.Items. Insert(0,string );

    Either way, the new string does not show up in the ComboBox. I get no errors or problems, it just will not work. At load time I am retrieving dates from an Oracle database and adding them to the ComboBox with out any problems. However, once the application is up and running I cannot add to the ComboBox. I have even tried saying ComboBox.Refres h() after adding or inserting the string, but it still does not show up. Has any one ever encountered this, and do you know how to fix it?

    --
    JOHN TYCE
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Cannot Insert or Add a String To a ComboBox

    John,

    Can you supply a code example? Are you binding to a data source for the
    list contents first? This might be the cause if you are getting the
    contents of the list this way.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m


    "John Tyce" <jtyce@chevront exaco.com> wrote in message
    news:OmUtIhByEH A.3808@TK2MSFTN GP15.phx.gbl...
    When a button is clicked, a date is inserted or added into a combo box like
    this : ComboBox.Items. Add(string) or ComboBox.Items. Insert(0,string );

    Either way, the new string does not show up in the ComboBox. I get no errors
    or problems, it just will not work. At load time I am retrieving dates from
    an Oracle database and adding them to the ComboBox with out any problems.
    However, once the application is up and running I cannot add to the
    ComboBox. I have even tried saying ComboBox.Refres h() after adding or
    inserting the string, but it still does not show up. Has any one ever
    encountered this, and do you know how to fix it?

    --
    JOHN TYCE


    Comment

    • John Tyce

      #3
      Re: Cannot Insert or Add a String To a ComboBox

      To better explain the problem, I cannot apply changes to a control when class instances are involved. For example: If I create a button on my main form and in that button's click event I write ComboBox.Items. Add(string), the string is added to the combo box without a problem. However, in my case, I am clicking a button on the main form which opens a dialog. Since it is a dialog, it is a separate form belonging to its own class. On that dialog a button is clicked. That buttons click event creates a new instance of the main forms class and calls a function in that class, passes it a string, and then calls ComboBox.Items. Add(string). In this case, the string does not show up in the combo box. Even if I insert new data into the database and then reload the combo box from the database the new data in the combo box will not show up unless I call form.Close() followed by form.Show(). I have already tried ComboBox.Refres h() and Update, neither helps. FYI the combo box is not bound to a datasource; I am simply looping through the rows and adding the column value of each row with the Items.Add function when populating the combo box (not when adding a single string). There has to be a way to insert a string into the combo box. I get the same results with a text box.

      --
      JOHN TYCE
      "John Tyce" <jtyce@chevront exaco.com> wrote in message news:OmUtIhByEH A.3808@TK2MSFTN GP15.phx.gbl...
      When a button is clicked, a date is inserted or added into a combo box like this : ComboBox.Items. Add(string) or ComboBox.Items. Insert(0,string );

      Either way, the new string does not show up in the ComboBox. I get no errors or problems, it just will not work. At load time I am retrieving dates from an Oracle database and adding them to the ComboBox with out any problems. However, once the application is up and running I cannot add to the ComboBox. I have even tried saying ComboBox.Refres h() after adding or inserting the string, but it still does not show up. Has any one ever encountered this, and do you know how to fix it?

      --
      JOHN TYCE

      Comment

      Working...