Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown box new items

Status
Not open for further replies.

bigdavelamb

Programmer
Jun 11, 2003
97
GB
I think I must be a complete idiot as i cannot work this out. All i want to do is have a dropdown box on my form (Winforms) and if the user enters a new item that is not on the list add this to the new database, What is the best method for this?

Hope someone can help me.
Dave.
 
While this may not be the best solution, it is a solution none the less. Whenever you load the page with the combobox, I would re-query the database so you have the most current values for the combobox. Something like:

Code:
private void PopulateCombo()
{
    string sql =  "SELECT DISTINCT <fields> FROM <tables> WHERE <conditions>";
    //Your connection code here
    ...

}

public void Form1_Load(...)
{
    PopulateCombo();
}

Hope this helps or sets your thinking on the right track!

--Brad

"Life is too important to be taken seriously" --Albert Einstein
 
hi, brad, i am fine with this side, the problem i have is to capture, the event when the user adds a new value to the dropdown (that is if they type in a brand new value), the combo does not seem to fire any events.

Cheers.
Dave
 
Dave,

Typically, as a GUI designer, you would not allow people to add new items that way.

You are better off to have an extra "Add" button that launches a new window or some kind of input box. Then the item from the user would get added.

Otherwise, if a person types "catt" and really meant to put in "Cat" but accidentally hit the wrong key, you can't undo that change.

Hope that helps.
 
I take your point there JurkMonkey, and i will implement it that way, however what's the purpose of dropdown feature then?

dave.
 
My opinion of the drop down is:

Give a user a drop down list which allows you to type in custom text in order to speed up the searching process. You should be typing in text and the best results from the list should show below. It is very rare that I would let custom text be the final value that I use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top