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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:56:35+00:00 2026-05-15T18:56:35+00:00

I need to convert int and or bool to checkState int ValueCheck; private void

  • 0

I need to convert int and or bool to checkState

int ValueCheck;      
private void gsCheck1_CheckedChanged(object sender, EventArgs e)
{
    CheckBox box = sender as CheckBox;
    box.CheckState = ValueCheck; // doesn't work
    this.gsCheck2.CheckState = ValueCheck; // should be 1 or 0 ?
}

As you can see I want to change (this.gsCheck2) CheckState by changeing (this.gsCheck1) CheckState and end up with a integer value which is need.

Update….
problem solved

private int ValueCheck(CheckState Check)
{
    if (Check == CheckState.Checked)
        return 1; 
    else
        return 0; 
}


private void gs_CheckedChanged(object sender, EventArgs e)
{
    CheckBox box = sender as CheckBox;
    MessageBox.Show(box.Name + "="+ ValueCheck(box.CheckState).ToString());
}
  • 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-15T18:56:35+00:00Added an answer on May 15, 2026 at 6:56 pm
    • Consider CheckBox.Checked which is the boolean property.
    • Use box.CheckState = (CheckState)ValueCheck;
    • You can also use the ?: operator.

    Update according to comments:

    Either declare the ValueCheck as a CheckState:

    CheckState ValueCheck;
    private void....
    

    Or convert the int value to a CheckState value:

    this.gsCheck2.CheckState = (CheckState)ValueCheck;
    

    The cast back the CheckState value to int:

    CheckState cs = box.CheckState;
    int ValueCheck = (int)cs;
    string result = "Current state: " + ValueCheck + cs.ToString();
    
    //You question:
    MessageBox.Show(box.Name + (int)box.CheckState);
    

    Update
    FYI, instead of writing the ValueCheck method, there is a C# operator ?: operator I mentioned above, which you can do:

    int result = box.CheckState == CheckState.Checked ? 1 : 0;
    

    Which is a translation of:

    int result;
    if (box.CheckState == CheckState.Checked)
        result = 1;
    else
        result = 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to convert a char array into int and float using C The
Criteria: Performance, Performance, Performance. I need a way to convert a uint, int, etc
I am trying to convert as following: bool foo(int a, unsigned short b) {
I need to convert a VARCHAR with a hex number to INT , I
Need to convert RGB or HEX colors to Long Int for another program that
I need to convert an ARGB hex into an int in Jython for color.
I need to convert Datetime fields to a specifically formatted INT type. For example,
I need to convert latitude/longitude coordinates into Easting/Northing coordinates in the Alberta 10 TM
I need to convert a named instance of SQL server 2005, to a default
I need to convert HTML documents into valid XML, preferably XHTML. What's the best

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.