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

The Archive Base Latest Questions

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

Currently we call a web service to check if user has permission to use

  • 0

Currently we call a web service to check if user has permission to use the chat room and we receive a 0 or a 1. I want to add to also be able to receive a 2, which will indicate it is enabled and authorized now
so I want to use three state check boxes, fully filled will mean he is authorized and also currently enabled (logged in), check will mean he is authorized but not enabled now, unchecked will mean he doesn’t have permission for this chat room.

Here is some code I currently use. FYI I took over this project from our developer and I’m kind of new to this, if you can give me an example even just for authtac1 then I’ll figure out how to do all others, and also do I need to add a new field ActiveTac1 like I have AuthTac1? Thanks for your help.

public partial class IMeditor : Form
{
    private IMuser imu;
    private IMui IMui;
    private IMdata IMdata;

    public IMeditor(IMui IMui, IMuser U, string Member)
    {
        InitializeComponent();
        this.IMui= IMui;
        imu = U;
        if (imu.UID == 0)
        {
            Add.Text = "Add";
            imu.MemberNick= Member;
        }
        else
            Add.Text = "Update";
        IMdata = new IMdata();
        MemberHandle.Text = imu.MemberHandle;
        IM.Text = imu.IM;
        AuthChat.Checked = imu.AuthChat == 1;
        AuthTac1.Checked = imu.AuthTac1 == 1;
        AuthTac2.Checked = imu.AuthTac2 == 1;
        AuthTac3.Checked = imu.AuthTac3 == 1;
        AuthTac4.Checked = imu.AuthTac4 == 1;



        switch (imu.Transport.ToLower()) {
            case "aim":   Transport.SelectedIndex = 0; break;
            case "gtalk": Transport.SelectedIndex = 1; break;
            case "msn":   Transport.SelectedIndex = 2; break;
            case "yahoo": Transport.SelectedIndex = 3; break;

}



    private void Add_Click(object sender, EventArgs e)
    {
        IMdata.AddIM(IMui.Username, IMui.Password, imu.UID, MemberHandle.Text, Transport.Text, IM.Text,
            AuthChat.Checked ? 1 : 0, 0, 
            AuthTac1.Checked ? 1 : 0, AuthTac2.Checked ? 1 : 0, AuthTac3.Checked ? 1 : 0,
            AuthTac4.Checked ? 1 : 0);
        Close();
    }

last question, to make sure I didnt screw up anything else
@competemt_tech this is what I ended up using (thanks so so much for your help, and our developer who was able to assist me)

To know how to set the checkboxes when i get the data from the webservice I used

 AuthChat.CheckState = GetCheckStateFromAuthCode(imu.AuthChat, imu.Enabled);
 AuthTac1.CheckState = GetCheckStateFromAuthCode(imu.AuthTac1, imu.Tac1Enabled);
 AuthTac2.CheckState = GetCheckStateFromAuthCode(imu.AuthTac2, imu.Tac2Enabled);
 AuthTac3.CheckState = GetCheckStateFromAuthCode(imu.AuthTac3, imu.Tac3Enabled);

and then I used:

 private CheckState GetCheckStateFromAuthCode(int AuthCode, int Enabled)
    {
        switch (AuthCode + Enabled)
        {
            case 0:
                return CheckState.Unchecked; // Unauthorized
            case 1:
                return CheckState.Checked;  // Authorized, not enabled
            case 2:
                return CheckState.Indeterminate; // Authorized and enabled
            default:
                return CheckState.Unchecked;
        }
    }

and after I make changes, to send back to the webservice I used:

imu.AuthChat, imu.Enabled = GetAuthCodeFromCheckState(AuthChat.CheckState),
imu.AuthTac1, imu.Tac1Enabled = GetAuthCodeFromCheckState(AuthTac1.CheckState),
imu.AuthTac2, imu.Tac2Enabled = GetAuthCodeFromCheckState(AuthTac2.CheckState),
imu.AuthTac3, imu.Tac3Enabled = GetAuthCodeFromCheckState(AuthTac3.CheckState),

and then I used:

private int GetAuthCodeFromCheckState(CheckState checkState)
    {
        switch (checkState)
        {
            case CheckState.Unchecked:  // Unauthorized
                return 0;
            case CheckState.Indeterminate:  // Authorized, not enabled
                return 1;
            case CheckState.Checked:  // Authorized and enabled
                return 2;
            default:
                return 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-27T03:13:29+00:00Added an answer on May 27, 2026 at 3:13 am

    Based on your code, it appears that you are using WinForms, not WPF, correct?

    If this is the case, then you will want to use the CheckState property of the checkbox and not Checked, since it supports three values:

    Unchecked = 0
    Checked = 1
    Indeterminate = 2
    

    Update

    In order to address your requirements, you would have code similar to the following:

    First, create a function that will generate the correct checkstate base on the authcode:

    private CheckState GetCheckStateFromAuthCode(int AuthCode)
    {
        switch (AuthCode)
        {
            case 0:
                // Unauthorized
                return CheckState.Unchecked;
    
            case 1:
                // Authorized, not enabled
                return CheckState.Indeterminate;
    
            case 2:
                // Authorized and enabled
                return CheckState.Checked;
    
            default:
                throw new ArgumentException("Unrecognized AuthCode value " + AuthCode.ToString());
        }
    }
    

    Then, use this code to set the state of your checkboxes:

    AuthChat.CheckState = GetCheckStateFromAuthCode(imu.AuthChat);
    AuthTac1.CheckState = GetCheckStateFromAuthCode(imu.AuthTac1);
    etc.
    

    Update 2

    In order to retrieve the authcode from the checkstate:

    First, create a function that will generate the correct checkstate base on the authcode:

    private int GetAuthCodeFromCheckState(CheckState checkState)
    {
        switch (checkState)
        {
            case CheckState.Unchecked:
                // Unauthorized
                return 0;
    
            case CheckState.Indeterminate:
                // Authorized, not enabled
                return 1;
    
            case CheckState.Checked:
                // Authorized and enabled
                return 2;
    
            default:
                throw new ArgumentException("Unrecognized checkState value " + checkState.ToString());
        }
    }
    

    Then, use this code to set the auth code from your checkboxes:

    imu.AuthChat = GetAuthCodeFromCheckState(AuthChat.CheckState);
    imu.AuthTac1 = GetAuthCodeFromCheckState(AuthTac1.CheckState);
    etc.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently i am using Handlers to call web service methods to make it run
I'm currently having trouble deserializing an XmlDocument from a web service call, here is
Currently I have webservice running on the Mono platform. When I call the service
I'm currently working on what I would call integration tests. I want to verify
Currently in my PHP-based applications I use a file, for instance services.php and call
I have to call a Web service that is extremely demanding (unstandard) regarding the
I am trying to figure out the best way to call a web service
I want to add a Remember Me check box to the login form of
making a call to a web service method with nusoap returns an error array(3)
I have the WSDL for a web service that I cannot currently connect to.

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.