tags:

views:

77

answers:

4

I have a form on that form I have a radiobutton

When the radiobutton changes I want to do some stuff. However I only want to do this if the FormLoad event has fired and dor some wierd reason the radiobutton changed event is getting hit prior to the FormLoad

Call stack is not much use, but its coming from the settings.designer.cs file Anyway short of setting a flag on the onLoadEvent is there some intrinsic property of the form like IsLoaded which i can use to make sure that my radio button code only executes once the form is loaded

A: 

Here is a different way...

RadioButton has an AutoCheck property which by default is set to true, you want to set this to false in the designer.

And then override it manually in the Form Load event to true like so:

radioButton1.AutoCheck = true;

You can set the CheckedChanged property setup in the designer still and it should work (won't trigger change event).

Jimmy Chandra
A: 

In the event handler, check to see if the radio button and/or form is visible. If the radio button's state is being changed before the form has been loaded, then RadioButton.Visible should be false.

NascarEd
A: 

You may also like to subscribe to the FormShown event. E.g:

private void Form1_Shown(object sender, EventArgs e)
{
   radioButton1.Checked = true;
}
baeltazor
A: 

You can check the IsHandleCreated property of your form to determine if the OnLoad has been called. This is the closest thing to a IsLoaded property.

Kleinux