Click here to Skip to main content
15,891,473 members
Home / Discussions / C#
   

C#

 
GeneralRe: Threading issue in winforms Pin
Mycroft Holmes1-Apr-09 18:10
professionalMycroft Holmes1-Apr-09 18:10 
GeneralRe: Threading issue in winforms Pin
N a v a n e e t h1-Apr-09 18:15
N a v a n e e t h1-Apr-09 18:15 
GeneralRe: Threading issue in winforms Pin
Luc Pattyn2-Apr-09 4:37
sitebuilderLuc Pattyn2-Apr-09 4:37 
QuestionVS 2008 Unit Testing Null Exception Error Pin
dboy2211-Apr-09 15:57
dboy2211-Apr-09 15:57 
AnswerRe: VS 2008 Unit Testing Null Exception Error Pin
Judah Gabriel Himango1-Apr-09 16:42
sponsorJudah Gabriel Himango1-Apr-09 16:42 
GeneralRe: VS 2008 Unit Testing Null Exception Error Pin
dboy2211-Apr-09 17:22
dboy2211-Apr-09 17:22 
QuestionCompleting a mulit-page webform using WebClient Pin
front711-Apr-09 15:18
front711-Apr-09 15:18 
QuestionComboBoxes and DataGridViews... Pin
Illegal Operation1-Apr-09 13:37
Illegal Operation1-Apr-09 13:37 
Hi,

I have a form that contains a ComboBox and a DataGridView. The ComboBox gets populated with all the countries as seen in the code below:

private void PopulateCountries()
{
    cbCountryId.DataSource = dsCountries.Tables["Country"];
    cbCountryId.DisplayMember = "Country";
    cbCountryId.ValueMember = "Id";
}


What I need to do is populate the DataGridView based on what country the user select. For example: if you select Australia then all the Australian states should display in the gridview. The code to display the states look like this:

private void GetStateByCountryId(int CountryId)
{
    this.dsWBGT_V4 = dataCommunicator.GetStateByCountryId(CountryId);
    this.stateBindingSource.DataSource = this.dsWBGT_V4;
}


As you can see I have a Property named CountryId but I cannot put it in the SelectedIndexChanged event because if the application start the event fires and I get an error because there was no selection in the ComboBox. I set the Property with this line:

CountryId = Convert.ToInt32(cbCountryId.SelectedValue);


Can anyone tell me how can I get the ComboBox to display a value by default at first run and set the property equal to that property so that the states in the selected country displays??

Illegal Operation

AnswerRe: ComboBoxes and DataGridViews... Pin
Mycroft Holmes1-Apr-09 16:27
professionalMycroft Holmes1-Apr-09 16:27 
GeneralRe: ComboBoxes and DataGridViews... Pin
Illegal Operation1-Apr-09 17:15
Illegal Operation1-Apr-09 17:15 
AnswerRe: ComboBoxes and DataGridViews... Pin
a.hamidy1-Apr-09 18:42
a.hamidy1-Apr-09 18:42 
QuestionSelf Update .Net application with a web service. Pin
Member 34269361-Apr-09 13:11
Member 34269361-Apr-09 13:11 
AnswerRe: Self Update .Net application with a web service. Pin
Judah Gabriel Himango1-Apr-09 16:24
sponsorJudah Gabriel Himango1-Apr-09 16:24 
Questionrename file Pin
yogesh_softworld1231-Apr-09 10:06
yogesh_softworld1231-Apr-09 10:06 
AnswerRe: rename file Pin
Pete O'Hanlon1-Apr-09 10:14
mvePete O'Hanlon1-Apr-09 10:14 
AnswerRe: rename file Pin
Giorgi Dalakishvili1-Apr-09 10:18
mentorGiorgi Dalakishvili1-Apr-09 10:18 
AnswerRe: rename file Pin
Henry Minute1-Apr-09 10:24
Henry Minute1-Apr-09 10:24 
QuestionExtracting an embedded resource file issue. Pin
astroudjr1-Apr-09 9:18
astroudjr1-Apr-09 9:18 
AnswerRe: Extracting an embedded resource file issue. Pin
Giorgi Dalakishvili1-Apr-09 10:08
mentorGiorgi Dalakishvili1-Apr-09 10:08 
AnswerRe: Extracting an embedded resource file issue. Pin
0x3c01-Apr-09 10:34
0x3c01-Apr-09 10:34 
QuestionAbout DMX protocol. Pin
pocho21011-Apr-09 8:32
pocho21011-Apr-09 8:32 
QuestionToolboxBitmap isn't working... The on going saga Pin
garaber1-Apr-09 8:19
garaber1-Apr-09 8:19 
AnswerRe: ToolboxBitmap isn't working... The on going saga Pin
Henry Minute1-Apr-09 10:30
Henry Minute1-Apr-09 10:30 
GeneralRe: ToolboxBitmap isn't working... The on going saga Pin
garaber1-Apr-09 14:33
garaber1-Apr-09 14:33 
GeneralRe: ToolboxBitmap isn't working... The on going saga Pin
Henry Minute2-Apr-09 1:09
Henry Minute2-Apr-09 1:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.