I have a string value with special characters like í, é, ?, ? etc. For example "San Luis Potosí". This value has been applied to a field in my application from a combobox on my form. Later on I want to find that value again in the combobox so the combobox is showing that value already. For 'normal' values it is working as expected and the combobox is showing the right value, but for values as "San Luis Potosí", "'s-Hertogenbosch" it is not. Is there a special thing I have to do in regards to these special characters?
Edit:
//Example:
txtLocation = "San Luis Potosí, Mexico";
string[] location = txtLocation.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
string city = location[0]; // city = "San Luis Potosí" (this works)
string country = location[1]; // country = "Mexico" (this works)
comboBoxCountry.SelectedIndex = comboBoxCountry.FindStringExact(country);
comboBoxCity.SelectedIndex = comboBoxCity.FindStringExact(city);
The comboboxes are filed by a dataset from a database. I am using winforms, framework .Net 4.6.1.
I just notice that it isn't working with any value. It appears it has nothing to do with any special characters.
I get these values when debugging.
comboBoxCountry.SelectedIndex = -1
comboBoxCity.SelectedIndex = -1
question from:
https://stackoverflow.com/questions/65916972/find-string-in-combobox 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…