Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0
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
Edited 14-Oct-12 3:17am
18.8K
v2
Comments
ridoy at 13-Oct-12 13:30pm
   
show us your code what you have tried..
D.M. Abdur Rahim at 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
0 OriginalGriff 383
1 Richard Deeming 180
2 ChauhanAjay 176
3 Sergey Alexandrovich Kryukov 171
4 Yogesh Kumar Tyagi 165
0 Sergey Alexandrovich Kryukov 6,252
1 OriginalGriff 5,498
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 14 Oct 2012
Copyright © CodeProject, 1999-2014
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