Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have 10 combo box divided by 2 groups. and a check box button. If I select checkbox then all value the first groups combobox will be the second group combobox's value.

I have tried and second group's combobox show the same text of first group comboboxe. but value is null.

Here is what I've done.

C#
private void chkSameAs_CheckedChanged(object sender, System.EventArgs e)
        {
            try
            {
                if (cboPresentDivision.Value != null)
                {
                    if (chkSameAs.Checked == true)
                    {
                        if (cboPresentDivision.Value != null)
                        { cboPermanentDivision.Value = cboPresentDivision.Text.Trim().ToString(); }
                        if (cboPresentDistrictZila.Value != null)
                        { cboPermanentDistrictZila.Value = cboPresentDistrictZila.Text.ToString(); }
                        if (cboPresentUpazilaThana.Value != null)
                        { cboPermanentUpazilaThana.Value = cboPresentUpazilaThana.Text.Trim().ToString(); }
                        if (cboPresentUnionWard.Value != null)
                        { cboPermanentUnionWard.Value = cboPresentUnionWard.Text.Trim().ToString(); }
                        if (cboPresentMouzaMohollah.Value != null)
                        { cboPermanentMauzaMoholla.Value = cboPresentMouzaMohollah.Text.Trim().ToString(); }
                        if (cboPresentVillage.Value != null)
                        { cboPermanentVillage.Value = cboPresentVillage.Text.Trim().ToString(); }
                        txtPermanentRoadHouse.Text = txtPresentRoadHouse.Text;
                    }
                    else
                    {
                        cboPermanentDivision.Value = string.Empty;
                        cboPermanentDistrictZila.Value = string.Empty;
                        cboPermanentUpazilaThana.Value = string.Empty;
                        cboPermanentUnionWard.Value = string.Empty;
                        cboPermanentMauzaMoholla.Value = string.Empty;
                        cboPermanentVillage.Value = string.Empty;
                        txtPermanentRoadHouse.Text = string.Empty;
                        cboPermanentDivision.DataSource = null;
                        cboPermanentDistrictZila.DataSource = null;
                        cboPermanentUpazilaThana.DataSource = null;
                        cboPermanentUnionWard.DataSource = null;
                        cboPermanentMauzaMoholla.DataSource = null;
                        cboPermanentVillage.DataSource = null;
                    }
                }
                else { objGeneral.MsgBox("Please select GEO Code value.", MessageBoxIcon.Information); }
            }
            catch (Exception ex) { objGeneral.MsgBox(ex.Message); }
Posted
Updated 14-Oct-12 3:17am
v2
Comments
ridoy 13-Oct-12 13:30pm    
show us your code what you have tried..
D.M. Abdur Rahim 14-Oct-12 4:36am    
private void chkSameAs_CheckedChanged(object sender, System.EventArgs e)
{
try
{
if(cboPresentDivision.Value!=null)
{

if(chkSameAs.Checked==true)
{
if(cboPresentDivision.Value!=null)
{
cboPermanentDivision.Value =cboPresentDivision.Text.Trim().ToString();
}

if(cboPresentDistrictZila.Value !=null)
{
cboPermanentDistrictZila.Value =cboPresentDistrictZila.Text.ToString();
}
if(cboPresentUpazilaThana.Value !=null)
{
cboPermanentUpazilaThana.Value=cboPresentUpazilaThana.Text.Trim().ToString();
}
if(cboPresentUnionWard.Value!=null)
{
cboPermanentUnionWard.Value = cboPresentUnionWard.Text.Trim().ToString();
}
if(cboPresentMouzaMohollah.Value!=null)
{
cboPermanentMauzaMoholla.Value=cboPresentMouzaMohollah.Text.Trim().ToString();
}
if(cboPresentVillage.Value!=null)
{
cboPermanentVillage.Value= cboPresentVillage.Text.Trim().ToString();
}
txtPermanentRoadHouse.Text = txtPresentRoadHouse.Text;

}
else
{
cboPermanentDivision.Value=string.Empty;
cboPermanentDistrictZila.Value =string.Empty;
cboPermanentUpazilaThana.Value=string.Empty;
cboPermanentUnionWard.Value = string.Empty;
cboPermanentMauzaMoholla.Value=string.Empty;
cboPermanentVillage.Value= string.Empty;
txtPermanentRoadHouse.Text = string.Empty;

cboPermanentDivision.DataSource=null;
cboPermanentDistrictZila.DataSource=null;
cboPermanentUpazilaThana.DataSource=null;
cboPermanentUnionWard.DataSource=null;
cboPermanentMauzaMoholla.DataSource=null;
cboPermanentVillage.DataSource=null;

}
}
else
{
objGeneral.MsgBox("Please select GEO Code value.",MessageBoxIcon.Information);
}
}
catch(Exception ex)
{
objGeneral.MsgBox(ex.Message);
}
}

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