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 6941219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:51:27+00:00 2026-05-27T12:51:27+00:00

I am trying to make a little game in C#. The program asks the

  • 0

I am trying to make a little game in C#.
The program asks the user for a any number.
The user then presses “GO” (button1) and the program checks whether the number is an even number or not. (x % 2 == 0)

I’m trying to get the program to show 4 checkboxes/radio buttons out of total of 8 depending on each case.
For example:

  • If the number is an EVEN NUMBER: The program will show options 2,5,3,6.
  • If the number is an ODD NUMBER: The program will show options 1,4,7,8.

(Options 1-8 were already included in the design.)

I need help with the if (x % 2 == 0) part. What do I write in it to make the checkboxes/radiobuttons appear or disappear?

By the way, is there a way to ask the user for a number without him having to click “GO”?
Like, use ENTER instead. If yes, what event is that?
Also, is there a way to limit the textbox to INT only?

I know it’s asking you to do the job, but I have tried, and I’m still a real beginner, therefore I think my way of learning is by actually experiencing it.

public partial class Form1 : Form
{
    int x;
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        x = int.Parse(textBox1.Text);
        if (x % 2 == 0)
        {
        }
    }
}
  • 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-27T12:51:28+00:00Added an answer on May 27, 2026 at 12:51 pm

    The Visible property of the CheckBox (inherited from Control) will aid you in making the needed controls visible when you wish them to be. Your if would look something like,

    if (num % 2 == 0) 
    {
        box1.Visible = false;
        box2.Visible = true;
        // ...
    }
    else
    {
        box1.Visible = true;
        box2.Visible = false;
        // ...
    }
    

    However, this can be optimized a bit by using the condition to set the visibility of all the CheckBoxs at the same time instead of coding two conditionals – something like:

    box1.Visible = !(num % 2 == 0);
    box2.Visible = (num % 2 == 0);
    // ...
    

    As for on pressing enter, check the OnKeyDown event for you control, you can do this through the designer. Your event method would look like:

    private void myControl_OnKeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            // Handle enter key pressed here
        }
    }
    

    This should help you with your problems.

    ADDITIONAL RESPONSE

    List<CheckBox> boxes = new List<CheckBox>();
    // Add all boxes and do other stuff, disable all
    
    foreach (CheckBox box in boxes)
    {
        box.Visible = false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to make a little Matrix themed program, I want the user
Okay so I'm trying to make a little gag program that will run away
I've been trying to make a little simple game just to test my logics,
HI all. I am trying to make little program that reads data from file
I'm trying to make a little rock paper scissors game. for that I've written
I'm trying to make a little program with Qt. I have a main.cpp with
I am making a little JS game and I am trying to make the
So what I'm trying to make is a little space game, You control the
I'm trying to make a little game that will first show the player a
Right now I'm trying make some browser based game. But I have little questions.

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.