I have a WinForms project with a bunch of fields. I'm loading a profile from my database into a Person object and then loading all Persons into a LIST of persons followed by setting a list box source to that list of persons. That's now working as expected!
I have had to add two countries onto my form, using ComboBox's. I've created a small Country class with CountryName and CoundeCode properties. On form load I'm creating a countryList variable, it's a LIST of Country and loading in all my applicable countries into it.
When I load my Person I have country and countryAlt being pulled from my database. Sometimes they are different sometimes they are the same.
When I do a listBox1_SelectedIndexChanged, I want to load the Person selected. However I seem to loop though it twice and get the same country in both ComboBoxes even if the values are different. If I load the CountryName into a textbox like this
I get four countries, two of each...
What is wrong?
I have had to add two countries onto my form, using ComboBox's. I've created a small Country class with CountryName and CoundeCode properties. On form load I'm creating a countryList variable, it's a LIST of Country and loading in all my applicable countries into it.
When I load my Person I have country and countryAlt being pulled from my database. Sometimes they are different sometimes they are the same.
When I do a listBox1_SelectedIndexChanged, I want to load the Person selected. However I seem to loop though it twice and get the same country in both ComboBoxes even if the values are different. If I load the CountryName into a textbox like this
C#:
TextBox1.Text += cCountry.CountryName.ToString();
I get four countries, two of each...
What is wrong?
C#:
Country cCountry = countryList.Find(i => i.CountryCode == thisPerson.Country.ToUpper().ToString());
countryList_box.Text = cCountry.CountryName.ToString();
Country aCountry = countryList.Find(i => i.CountryCode == thisPerson.CountryAlt.ToUpper().ToString());
altCountryList_box.Text = aCountry.CountryName.ToString();