By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,017 Members | 1,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,017 IT Pros & Developers. It's quick & easy.

Cannot Insert or Add a String To a ComboBox

P: n/a
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.Refresh() 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
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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]
- mv*@spam.guard.caspershouse.com
"John Tyce" <jt***@chevrontexaco.com> wrote in message
news:Om**************@TK2MSFTNGP15.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.Refresh() 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
Nov 16 '05 #2

P: n/a
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.Refresh() 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" <jt***@chevrontexaco.com> wrote in message news:Om**************@TK2MSFTNGP15.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.Refresh() 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
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.