locked
Do you have any idea about this problem? RRS feed

  • Question


  • let say if i dun want to uncheck the checkbox what code should i used. any idea pls help me 
    Wednesday, February 3, 2010 4:41 PM

Answers

  • Hi kar kar,

    You can use CheckBox control and set AutoCheck property to false.
    This way it will not be automatically checked when user clicks it, but you can still check/uncheck it programmatically through Checked property.
    Handle the click event and display your message.

    Best regards,
    Helen Zhou

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Helen Zhou Tuesday, February 9, 2010 8:33 AM
    Monday, February 8, 2010 7:21 AM

All replies

  • Hi,

    set AutoCheck on checkbox to false.
    handle click event and manually set Checked property to true if you need to.

    hope this helps
    Vladimir

    EDIT: I just saw you have the same question  (unless I misunderstood you) in a different thread ... 
    Was it not solved or is this somehow different ?


     
    • Proposed as answer by Rudedog2 Monday, February 8, 2010 1:47 PM
    Wednesday, February 3, 2010 4:59 PM

  • let say if i dun want to uncheck the checkbox what code should i used. any idea pls help me 


    Code?  Okay.  Which language?

    Mark the best replies as answers. "Fooling computers since 1971."
    Wednesday, February 3, 2010 5:14 PM
  • no my fri, my problem is that honestly i m creating a game. And this game allow player one to check 1 box then he can't uncheck that one. and for player 2 he also can uncheck player1's and he can also do in the other limited check box. The game is called the pyramid. You may help me much better if you know that game. :)
     THanks anyway.
    Wednesday, February 3, 2010 5:32 PM
  • C# pls
    thanks
    Wednesday, February 3, 2010 5:33 PM
  • Use this custom control for our checkbox.


        class NoCheckCheckBox : CheckBox
        {
            public bool NoCheckEnabled
            {
                get;
                set;
            }
            public NoCheckCheckBox()
            {
                this.CheckStateChanged +=
                    new EventHandler(NoCheckCheckBox_CheckStateChanged);
            }

            void NoCheckCheckBox_CheckStateChanged(object sender, EventArgs e)
            {
                if (this.NoCheckEnabled)
                {
                    this.CheckStateChanged -=
                        new EventHandler(NoCheckCheckBox_CheckStateChanged);
                    this.CheckState = CheckState.Unchecked;
                    this.CheckStateChanged +=
                        new EventHandler(NoCheckCheckBox_CheckStateChanged);
                }
            }


    Use it like this....


            public Form1()
            {
                InitializeComponent();
                this.noCheckCheckBox1.NoCheckEnabled = true;
            }



    Rudy  =8^D

    Mark the best replies as answers. "Fooling computers since 1971."
    Wednesday, February 3, 2010 5:53 PM
  • r u a programmer?
    Incredible. Thanks! :)  I know that will work. 
    Wednesday, February 3, 2010 5:58 PM
  • OK,I'll try one more time ... AutoCheck property specifies whether checkbox will be checked/unchecked when user clicks on it.
    there is no need to implement that functionallity as far as i can see.

    I never heard of the game and didn't really understand the description.

    scenario 1: When player 1 checks a checkbox no one (not player 1 nor player 2) can uncheck it  anymore --> you just need to handle the Checked event on a checkbox  and set AutoCheck to false. That way you locked it forever.

    scenario 2: When player 1 checks a checkbox he (player 1) can not uncheck it  anymore, but player 2 can uncheck it (a player can not uncheck his own checkboxes but can uncheck the other player's checkboxes) --> every time a user gets to play you need to iterate through the collection of his checkboxes and set each one Autocheck to false, then iterate through the all other checked checkboxes and set their AutoCheck property to false.
    Or more generally, if you have some other rules which checkboxes are locked, everytime before a player get's to play a move, iterate through all checkboxes and lock/unlock them according to the game logic. Lock --> set Autocheck to true; Unlock --> set AutoCheck to false

    I hope this can help you, or you already got it from Rudy's answer ... good luck with the game,
    vladimir
    • Proposed as answer by Rudedog2 Thursday, February 4, 2010 2:21 PM
    Wednesday, February 3, 2010 11:40 PM
  • Hi kar kar,

    You can use CheckBox control and set AutoCheck property to false.
    This way it will not be automatically checked when user clicks it, but you can still check/uncheck it programmatically through Checked property.
    Handle the click event and display your message.

    Best regards,
    Helen Zhou

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Helen Zhou Tuesday, February 9, 2010 8:33 AM
    Monday, February 8, 2010 7:21 AM
  • isnt it simpler if You check the checkBox and then set its Enabled property to false ? Strongly indicating that player is not allowed to uncheck that checkbox ? Setting Enabled=true will allow unchecking again if its needed.
    Thanks

    Real Programmers don't comment their code. If it was hard to write, it should be hard to understand.
    My BlogMy Facebook
    Tuesday, February 9, 2010 5:35 AM