This is my program:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CountryCurrency
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        }

        private void rdbRupees_Click(object sender, EventArgs e)
    {
        if (rdbIndia.Checked == true)
            MessageBox.Show("You are right");
        else
            MessageBox.Show("Select proper currency");
    }

    private void rdbYen_Click(object sender, EventArgs e)
    {
        if (rdbJapan.Checked == true)
            MessageBox.Show("You are right");
        else
            MessageBox.Show("Select proper currency");
    }

    private void rdbDollers_Click(object sender, EventArgs e)
    {
        if (rdbUSA.Checked == true)
            MessageBox.Show("You are right");
        else
            MessageBox.Show("Select proper currency");
    }


    }
}

This is how form look like

ConCurr

so the problem is when i click on any currency to validate that it is true for the country or false for the country.
It displays message box for Yen & Rupees but didn't show any message box for Dollers.
Can anyone tell me where I am having problem in the program.

If i use CheckedChanged event it displays message box twice.

For e.g. India is already checked then if i check Rupees, message box appears once.
After that if i clicked Yen, it give me two message boxes telling me i am right first time then wrong second time.
After if i click Dollers, it give me two message boxes telling i am wrong, displaying twice.

So i used Click() but still didn't got satisfactory results .
Can anyone help me

You could always add a button that would validate your choices. The only time a message box would display results is when the button is clicked. FYI "dollars"

But i have to validate it using radiobuttons only

can anyone find solution to this

This is another code when i click the radio buton CheckedChanged event.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CountryCurrency
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            rdbIndia.Checked = true;
        }

        private void rdbRupees_CheckedChanged(object sender, EventArgs e)
        {
            if (rdbIndia.Checked)
                MessageBox.Show("You are right");
            else if (rdbJapan.Checked)
                MessageBox.Show("Select proper currency");
            else if (rdbUSA.Checked)
                MessageBox.Show("Select proper currency");
            rdbIndia.Checked = false;
        }

        private void rdbYen_CheckedChanged(object sender, EventArgs e)
        {
            if (rdbJapan.Checked)
                MessageBox.Show("You are right");
            else if (rdbIndia.Checked)
                MessageBox.Show("Select proper currency");
            else if (rdbUSA.Checked)
                MessageBox.Show("Select proper currency");
            rdbJapan.Checked = false;
        }

        private void rdbDollers_CheckedChanged(object sender, EventArgs e)
        {
            if (rdbUSA.Checked)
                MessageBox.Show("You are right");
            else if (rdbJapan.Checked)
                MessageBox.Show("Select proper currency");
            else if (rdbIndia.Checked)
                MessageBox.Show("Select proper currency");
            rdbUSA.Checked = false;
        }

        private void rdbIndia_CheckedChanged(object sender, EventArgs e)
        {
            if (rdbRupees.Checked)
                MessageBox.Show("You are right");
            else if (rdbYen.Checked)
                MessageBox.Show("Select proper country");
            else if (rdbDollers.Checked)
                MessageBox.Show("Select proper country");
            rdbRupees.Checked = false;
        }

        private void rdbJapan_CheckedChanged(object sender, EventArgs e)
        {
            if (rdbYen.Checked)
                MessageBox.Show("You are right");
            else if (rdbRupees.Checked)
                MessageBox.Show("Select proper country");
            else if (rdbDollers.Checked)
                MessageBox.Show("Select proper country");
            rdbYen.Checked = false;
        }

        private void rdbUSA_CheckedChanged(object sender, EventArgs e)
        {
            if (rdbDollers.Checked)
                MessageBox.Show("You are right");
            else if (rdbYen.Checked)
                MessageBox.Show("Select proper country");
            else if (rdbRupees.Checked)
                MessageBox.Show("Select proper country");
            rdbDollers.Checked = false;
        }

Here again the problem is if i check the next radiobutton it displays messagebox twice.
I don't know what to do now. ConCurr1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.