You can't access checkboxes or any other controls before you have called InitializeComponent - it sets up the control instances, so until then you will always get "Object not set to an instance of an object" errors.
"Is what you are trying to do have an optional splash screen that does or doesn't show up *next* time the application is started?
yesss i am trying to do that
my english is not so good so there is problem that you havent understood.
so bro. how can i do that?
firstly a splash screen is shown but when user login and checked the checkbox that do not show the splash screen at startup then splash screen will not been shown to him.
now you have understood. can you help me out in this.
thanks in advance sir"
OK. The first thing to do is to save the Checkbox status somewhere. The easiest way to do this is to use the Settings built into .NET and VS.
1) Look in the Solution Explorer pane, under you project.
2) Find "Properties" and expand it.
3) Under properties you should find "Settings.Settings" - double click it.
4) In the window that appears, add a new setting, by:
4.1) Change "Setting" under "Name" to "ShowSplashScreen".
4.2) Change "Type" to "Bool".
4.3) Set "Value" to "True"
Close the window - save changes if it asks.
In your code, when you want to decide if you should show a splashscreen:
if (Properties.Settings.Default.ShowSplashScreen)
{
...
}
When you change the Checkbox, save the new value:
Properties.Settings.Default.ShowSplashScreen = splashScreenCheckBox.Checked;
Properties.Settings.Default.Save();
In your Form constructor, set the check box:
public frmMain()
{
InitializeComponent();
splashScreenCheckBox.Checked = Properties.Settings.Default.ShowSplashScreen;
}
Done!