Click here to Skip to main content
Sign Up to vote bad
good
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:49
Edited 14 Oct '12 - 3:17

Comments
ridoy - 13 Oct '12 - 13:30
show us your code what you have tried..
D.M. Abdur Rahim - 14 Oct '12 - 4:36
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
Your Filters
Interested
Ignored
     
0 OriginalGriff 310
1 Aarti Meswania 250
2 Sergey Alexandrovich Kryukov 249
3 Slacker007 240
4 Ron Beyer 190
0 Sergey Alexandrovich Kryukov 8,598
1 OriginalGriff 7,024
2 CPallini 3,668
3 Rohan Leuva 3,011
4 Maciej Los 2,343


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 14 Oct 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid