Click here to Skip to main content
15,743,429 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a combobox and that is populated with list of country.if i edit the datagridview row it will also set the country according to the value. but combobox did not select value

below is my code

What I have tried:

public long CountryID { get; set; }

private async void PopulateCountry(bool IsRequired)
           if (IsRequired)
                   var countrylist = await Shared.PopulateCountry();
                   if (countrylist.Any())
                       CmbCountry.ValueMember = "ID";
                       CmbCountry.DisplayMember = "Text";
                       CmbCountry.DataSource = countrylist;

                       if (_CountryID > 0)
                           CmbCountry.SelectedValue = _CountryID;

               catch (Exception ex)


Updated 16-Sep-16 1:18am
[no name] 16-Sep-16 6:33am    
Debug your code and find out. And, stop ignoring exceptions.

1 solution

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.
When the code don't do what is expected, you are close to a bug.

As you already been told, remove the try catch to get notices of errors.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900