Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4240748
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:12:27+00:00 2026-05-21T03:12:27+00:00

I have 2 forms. I would like to check a radio button as soon

  • 0

I have 2 forms. I would like to check a radio button as soon as I load another form (the button is in the second form). I tried

OnLoad(radioButton2.Checked) 

but it hasnt worked. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T03:12:28+00:00Added an answer on May 21, 2026 at 3:12 am

    If I understand correctly, you have a radio button on one of your forms (let’s refer to it as form1 so we can distinguish it), and want to alter it upon loading another form (which I’ll refer here as form2).

    There are several things you need to keep in mind:

    1. You need to ensure that the button is accessible from outside form1. If both forms are part of the same project (which I guess it’s the case), then you need to ensure that the button is one of protected internal, internal, or public.
    2. form1 is actually a class; but the form that shows up on your screen isn’t the form1 class itself: it is an instance of the class. You will need a reference to that instance.
    3. To reach a member of an object, you use the . (dot) operator. For example, if your instance of form1 was named myForm1, then you would need to type myForm1.radioButton2 to refer to the radio button. When you omit the object reference, it defaults to the current object (this is, the object whose code is executing). So when you are typing code for form1 you can omit the reference, but to access it from form2, you need it (otherwise, the compiler will think that you are trying to reach something named “radioButton2” within form2, which probably doesn’t even exist).
    4. A radio button’s Checked is a property (more specifically, a bool property): you can get or set the values of properties, but refering to a property without doing anything with it is normally pointless, and on most cases won’t even compile.
    5. If you want to execute code in response to some event, then you need to register an event handler. An event handler is just a function that returns void and takes a couple of arguments (an object and an EventArgs or some subclass of it). Registering the handler can be done programaticaly, but you’re probably better off doing it from the designer. To create and register an event handler, follow these steps:
      5.1. Select the form on the designer, and go to the Properties window.
      5.2. Switch to the events view (a small lightning icon)
      5.3. Find the event you want to handle. In this case, OnLoad, and double-click on it.
      5.4. Voilà! The designer has created a method stub for your new event handler, registered it for the event, and sent you into the code view so you can fill it up.

    So, assuming you have the reference to your form1 instance (I’ll get into that soon), to mark the radio button you would need a statement like this:

    myForm1.radioButton2.Checked = true;
    

    This will set the Checked property of the radioButton2 control contained on the myForm1 instance of the form1 class to true; which effectively makes the radio button to appear checked.

    Now, to the juicy part: how to get a reference to the form? That depends on how you (or the IDE, on your behalf) created it.
    If form1 is the startup form of your application, and you are sticking to the default way to do things in Visual Studio, then take a look at the Program class the Studio created for your project. There should be a function there, named Main. At some point, you’ll see a line similar to this:

    Application.Run(new form1());
    

    the new form1() part creates a new instance of form1, and passes it to Application.Run() (don’t bother too much now about what this call does, we are only interested on the reference). The problem is that the reference is used on the fly and not saved, but we can fix that: add something like this on the Program class, outside Main:

    internal static form1 myForm1;
    

    Then replace the Application.Run() call with these two lines:

    myForm1 = new form1();
    Application.Run(myForm1);
    

    The call will do the same thing, but by breaking it down into two steps, we got the ability to save the reference to the static field myForm1.
    Now, from anywhere on your program, you can use Program.myForm1 to refer to that form. So, on your OnLoad event handler in form2, all you need to do is:

    Program.myForm1.radioButton2.Checked = true;
    

    Despite all of this, if you are “calling” your form2 from form1, then you can save yourself some tedious work by checking the button just before passing control to the secondary form, something like this:

    radioButton2.Checked = true;
    // Code that shows your "form2" goes here.
    

    On either case, remember to replace form1 and form2 with the actual names of your forms.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a resize indication on a windows forms Form (the
I would like to have a window with a simple form (radio buttons and
My forms have checkboxes and I would like to replace the normal arrow check
I would like to check if there are blank embedded forms into my form,
I have a form around a list of items. I would like to check
I have a Tcl/Tk app that generates many forms and would like to be
I have a form that I would like to style. specifcally I would like
I would like to have Ajax form in Rails so i'm using form_remote_tag. The
I would like to have a form that can submit to two different action
I have a form which includes a data sheet. I would like to make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.