Sir, I need your help.
I have three comboBoxes - cmbCountry, cmbState and cmbDistrict.
I called cmbCountry filling in Form_Load and sets its Index to zero.
I called cmbState comboBox fill in SelectedValueChanged event of cmbCountry. Its index sets to -1.
The core area of my problem is from here.
Currently, cmbDistrict comboBox is invisible. Only when I select a state, I want to fill and visible the cmbDistrict .
Here my code:-
private void cmbCountry_SelectedValueChanged(object sender, EventArgs e)
{
try
{
if (cmbCountry.SelectedIndex > -1 && cmbCountry.SelectedValue.ToString() != "System.Data.DataRowView")
{
StateComboFill();
}
}
catch (Exception)
{
throw;
}
}
private void cmbState_SelectedValueChanged(object sender, EventArgs e)
{
try
{
if (cmbState.SelectedIndex>-1 && cmbState.Text != "System.Data.DataRowView")
{
lblDistrict.Visible = true;
cmbDistrict.Visible = true;
FillDistrict();
}
}
catch (Exception)
{
throw;
}
}
private void cmbDistrict._SelectedValueChanged(object sender, EventArgs e)
{
try
{
if (cmbDistrict..SelectedValue.ToString() != null && cmbDistrict..SelectedValue.ToString() != "System.Data.DataRowView" &&cmbDistrict.SelectedIndex != -1)
{
FillGridCorrespondingToDistrict();
}
}
}
}
catch (Exception)
{
throw;
}
}
my current prblem is when i select a country, cmbDistrict combo is visible and data filled into it.
Loading


Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Nov 13, 2013, 8:05 PM EST
What are you doing at StateComboFill();
Bineesh ViswanathRank #1,680 · 907 reputationPosted Nov 13, 2013, 9:37 PM EST
cmbCountry: India
cmbState:Maharashtra(only to be fill if country is selected)
cmbDistrict:Mumbai(only to be fill if state is selected)
current problem is that when i select country, cmbState and cmbDistrict is being filled.
Hanook159 reputationPosted Nov 14, 2013, 1:36 AM EST
http://csharpdotnetfreak.blogspot.com/2012/07/cascading-combobox-in-winforms-windows-forms.html
http://www.c-sharpcorner.com/UploadFile/vemuhemanth/cascading-dropdown-in-Asp-Net-using-jquery/
braj sharma82 reputationPosted Nov 19, 2013, 10:54 PM EST
Girish Sapariya159 reputationPosted Nov 20, 2013, 2:10 AM EST
1: You filling your country combobox.
2: After filling country combo, selection change event is fired and function to get state combo is called.
3: Next your state combo is filled, now here please check that after filling state combobox,
by-default 0th index is selected or not, if yes then that cause to fire selection change event of state combo and hence your function to get district gets called
4: Then your district combo is filled.
please check it and let us know.