I have been trying to load a text file into a combobox, and then making a button to save any changes I make in the combobox back to the text file.
The problem is, when I type something in my combobox, the selected 'item' doesn't get updated. I can change the sentence, but as soon as I click the 'save' button, which also updates the combobox, it goes back to before I edited it.
Also, when I edit the combobox and click the dropdown-arrow, it shows the content of the text file, once again without my edited sentence.
I've been searching for a while now, but nobody seems to know how to do it so far. :P
private void cbBanken_SelectedValueChanged(object sender, EventArgs e)
{
this.cbBanken.Update();
}
I thought something like that might work, but it doesn't do anything. I did manage to ádd a new item to the list after changing it, but that's not what I want. I want to be able to edit the items, not add a new one.
I hope this is detailed enough. Thank you for your time!
Edit: Alright, just one more thing: "It will only update the first character I change. So if I use backspace anywhere, it updates, and then I have to restart before it will update again. Also, it will go to the far left of the combobox line, which can be pretty annoying.. If anyone knows how to fix that too, I'd be really gratefull."
I am currently using this code:
private void comboBox1_TextChanged(object sender, EventArgs e)
{
if(comboBox1.SelectedIndex>=0)
{
int index = comboBox1.SelectedIndex;
comboBox1.Items[index] = comboBox1.Text;
}
}