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

Girish SapariyaPosted Nov 20, 2013, 7:10 AM
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.
braj sharmaPosted Nov 20, 2013, 3:54 AM
HanookPosted Nov 14, 2013, 6:36 AM
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/
Bineesh ViswanathPosted Nov 14, 2013, 2:37 AM
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.
Jaganathan BantheswaranPosted Nov 14, 2013, 1:05 AM
What are you doing at StateComboFill();