I have following code in my WPF application where I fill combobox, so when I run application, combobox is already prefilled:
combo.Items.Add("first");
combo.Items.Add("second");
combo.Items.Add("third");
Is there anyway I can add values to combobox from client side? I mean, I run application, then for example double click on combobox, start typing some value, hit enter, it saves that value and its forever added to combobox? I would like to implement this feature, but I just dont know how.
EDIT: Okay we fixed first issue. I want to ask one more question. How can I do it if I want to add new link and have it in combobox forever? Next time I start app again, my added links are gone :( I want to have them here till I delete them. Am I able to do it without database? Just in application background?
EDIT2: I discovered application setting, am I somehow able to maintain list of values, which will fill combobox and I will also add values from GUI and when I exit app, this updated list will save in setting, so next time it will open with updated combobox? Any ideas? Thank you
You'll need some sort of TextBox
to enter the new text. As for getting the typed-in text to the ComboBox
, having an "add" button is going to be easiest, but you can also check for the ENTER key in the KeyUp
event of the TextBox
.
In the click event handler of the Button
or the KeyUp
event handler of the TextBox
, whichever route you decide to go, you just add the new item:
combo.Items.Add(textBox1.Text);