Click here to Skip to main content
12,950,272 members (68,407 online)
Rate this:
 
Please Sign up or sign in to 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.

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 13-Oct-12 6:49am
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)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,829
CHill60 3,460
Maciej Los 2,953
Jochen Arndt 1,975
ppolymorphe 1,820


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 14 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100