private void rbWeek_CheckedChanged(object sender, EventArgs e)
        {
            if (rbWeek.Enabled == true)
            {
                DialogResult dChangeCycle = MessageBox.Show("Yes to start new billing cycle from today's date. No will make no changes to next billing Date.", "Next Billing Date Change", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dChangeCycle == DialogResult.No)
                {

                }
                else if (dChangeCycle == DialogResult.Yes)
                {
                    dtpBillDate.Value = DateTime.Now.AddDays(7);
                }
                billing_CycleTextBox.Text = "Weekly";
            }
        }

I can't see why it is running the messagebox twice.

break showed it fire the Message Box right but as soon as you press yes or no it fired it again with no break?

I is confuseded....

Hmmm it may be possible that you have multiple radio boxes subscribing to this event (I suspect there are 2). If that is the case, when you click a radio button it will fire the event since the button's checked value will change. But the nature of a radio button is that when one is changed, the old selected one changes too (it becomes unselected). This would explain why the event is fired twice.

One way to solve this would be to check the selected radio button. It seems like you are trying to do this, but rbWeek.Enabled is not the property to check - this is checking if the control is enabled (a disabled control appears gray and does not allow user interaction). I don't remember the exact name of the property to determine if a radio button is checked, but it is something along the lines of rbWeek.Checked.

commented: thanks helped me see the issue better +2

the enable check is placed because when form loads everything is enabled false as it populate from database then edit button changes from viewing mode to edit

enable sets so it does not fire on form load

I have multiple radiobuttons for week,bi-month,month,quarter, bi-annual, and annual
each with own CheckedChanged event

I guess it is possible it fires twice since you are removing one and populating the other but how would i cancel this effect maybe add:

if (rbWeek.Enabled == true && rbWeek.Checked == true)

I will attempt this and let you know.

Yes adding the && rb.checked == true to each radio button event as above did it thank you

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.