Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have five check boxes in a Group Box, with each each box having different selections on another radio button Group.

If I select One check box at a time, I can achieve what I am supposed to in the radio button.
But if I select more than one check box in any sequence, I am just achieving the last check box that I clicked. But I need to achieve the other check boxes purpose too.
How can I achieve this??? Any easy logic???

Kindly help me in this to solve this with minimal coding.
Thanks in advance.

The following is the below line code,

C#
private void chk_Balanced_CheckedChanged(object sender, EventArgs e)
{
    if (chk_Balanced.Checked == true)
    {
        radio_2ch.Enabled = true;
        radio_6ch.Enabled = true;
        radio_8ch.Enabled = true;
        radio_48.Enabled = false;
        radio_96.Enabled = false;
        radio_192.Enabled = false;
    }
}

private void chk_Unbalanced_CheckedChanged(object sender, EventArgs e)
{
    if (chk_Unbalanced.Checked == true)
    {
        radio_2ch.Enabled = true;
        radio_6ch.Enabled = true;
        radio_8ch.Enabled = true;
        radio_48.Enabled = false;
        radio_96.Enabled = false;
        radio_192.Enabled = false;
    }
}

private void chk_Headphone_CheckedChanged(object sender, EventArgs e)
{
    if (chk_Headphone.Checked == true)
    {
        radio_2ch.Enabled = true;
        radio_6ch.Enabled = false;
        radio_8ch.Enabled = false;
        radio_48.Enabled = false;
        radio_96.Enabled = false;
        radio_192.Enabled = false;
    }
}

private void chk_HDMI_CheckedChanged(object sender, EventArgs e)
{
    if (chk_HDMI.Checked == true)
    {
        radio_2ch.Enabled = false;
        radio_6ch.Enabled = false;
        radio_8ch.Enabled = false;
        radio_48.Enabled = true;
        radio_96.Enabled = true;
        radio_192.Enabled = true;
    }
}

private void chk_SPDIF_CheckedChanged(object sender, EventArgs e)
{
    if (chk_SPDIF.Checked == true)
    {
        radio_2ch.Enabled = false;
        radio_6ch.Enabled = false;
        radio_8ch.Enabled = false;
        radio_48.Enabled = true;
        radio_96.Enabled = true;
        radio_192.Enabled = true;
    }
}
Posted
Updated 12-Feb-14 18:49pm
v3
Comments
TrushnaK 13-Feb-14 0:08am    
which logic you executing on single checkbox click and what you want to achieve on multiple checkbox selection..... improve your question with details and some code.
Prasad Avunoori 13-Feb-14 4:31am    
Do you want to write the code in one method instead of Five?

1 solution

Step 1: Select all Five Checkboxes in Designer then chang the Checked_Changed Event to "chkGroup_CheckedChanged"


Step 2: Then replace your code with following Code

C#
private void chkGroup_CheckedChanged(object sender, EventArgs e)
       {
         if (sender.Equals(chk_Balanced))
           {
               radio_2ch.Enabled = true;
               radio_6ch.Enabled = true;
               radio_8ch.Enabled = true;
               radio_48.Enabled = false;
               radio_96.Enabled = false;
               radio_192.Enabled = false;
           }
           else if (sender.Equals(chk_Unbalanced))

           {
               radio_2ch.Enabled = true;
               radio_6ch.Enabled = true;
               radio_8ch.Enabled = true;
               radio_48.Enabled = false;
               radio_96.Enabled = false;
               radio_192.Enabled = false;
           }

           else if (sender.Equals(chk_Headphone))

           {
               radio_2ch.Enabled = true;
               radio_6ch.Enabled = false;
               radio_8ch.Enabled = false;
               radio_48.Enabled = false;
               radio_96.Enabled = false;
               radio_192.Enabled = false;
           }
           else if (sender.Equals(chk_HDMI))

           {
               radio_2ch.Enabled = false;
               radio_6ch.Enabled = false;
               radio_8ch.Enabled = false;
               radio_48.Enabled = true;
               radio_96.Enabled = true;
               radio_192.Enabled = true;
           }

           else  if (sender.Equals(chk_SPDIF))

           {
               radio_2ch.Enabled = false;
               radio_6ch.Enabled = false;
               radio_8ch.Enabled = false;
               radio_48.Enabled = true;
               radio_96.Enabled = true;
               radio_192.Enabled = true;
           }




       }
 
Share this answer
 

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