Thread: Checkbox Errors

Results 1 to 4 of 4
  1. #1
    Ravin' Rabbid's Avatar
    Join Date
    Aug 2013
    Gender
    male
    Location
    In Your Backyard
    Posts
    17
    Reputation
    16
    Thanks
    0
    My Mood
    Confused

    Question Checkbox Errors

    No matter what combination I try to use I continue to get this same error

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Web;
    
    namespace Page_75_Exercise
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                if (checkBox1.Checked == true)
                {
    
                    if (label1.BackColor == Color.Red)
                    {
    
                        label1.BackColor = Color.Blue;
                    }
    
                    else
                    {
                        label1.BackColor = Color.Red;
                    }
    
                }
                else
                {
                    MessageBox.Show("The Checkbox is not selected!");
                }
            }
        }
    }
    My error
    Attached Thumbnails Attached Thumbnails
    2nq8sqb.png  


  2. #2
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    When you double-click on a control in the GUI editor, 2 things happen

    1) It takes you to the code. If it doesn't exist yet, it will create the default (Click for buttons, CheckChanged for this, etc etc) event code.
    2) It hooks up the event handler is the "background form partial class".

    You erased the function "checkBox1_CheckedChanged", but VS wasn't smart enough to detect that and still tries to hook up the checkbox's event to a function that doesn't exists anymore. ?

    Just erase the line hooking up the event.


    In the Form1 code, right click on "InitializeComponent" and select "Go to Definition", it will take you to Form1.Designer.Cs, the other "partial class" for the form1, where the controls code is kept. Inside that function is where the event handler normally gets hooked up. In your screenshot, the line with the error. * Erase it, you don't actually care about that event.
    Last edited by abuckau907; 08-29-2013 at 02:38 AM. Reason: ? *
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  3. #3
    Ravin' Rabbid's Avatar
    Join Date
    Aug 2013
    Gender
    male
    Location
    In Your Backyard
    Posts
    17
    Reputation
    16
    Thanks
    0
    My Mood
    Confused
    Quote Originally Posted by abuckau907 View Post
    When you double-click on a control in the GUI editor, 2 things happen

    1) It takes you to the code. If it doesn't exist yet, it will create the default (Click for buttons, CheckChanged for this, etc etc) event code.
    2) It hooks up the event handler is the "background form partial class".

    You erased the function "checkBox1_CheckedChanged", but VS wasn't smart enough to detect that and still tries to hook up the checkbox's event to a function that doesn't exists anymore. ?

    Just erase the line hooking up the event.


    In the Form1 code, right click on "InitializeComponent" and select "Go to Definition", it will take you to Form1.Designer.Cs, the other "partial class" for the form1, where the controls code is kept. Inside that function is where the event handler normally gets hooked up. In your screenshot, the line with the error. * Erase it, you don't actually care about that event.
    Suprised I didn't try that lol, thanks for the help it worked.

  4. #4
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    Haha, it's probably better than you don't just erase lines with errors in them : p


    Sometimes the IDE is nice for doing things in the background, sometimes not nice. In VB it would have auto-erased the event hookup if you erased the function ; D Thanks for the Thanks, see ya.
    Last edited by abuckau907; 08-29-2013 at 07:20 PM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

Similar Threads

  1. [Detected] Jack987 CheckBoX v1.1
    By jack987 in forum Combat Arms Brazil Hacks
    Replies: 7
    Last Post: 04-20-2011, 12:49 PM
  2. [Hep]injector checkbox
    By DS45SD in forum Visual Basic Programming
    Replies: 3
    Last Post: 12-05-2010, 10:24 PM
  3. [HELP] FormClosed in Checkbox
    By XxDragonSharKxX in forum Visual Basic Programming
    Replies: 22
    Last Post: 07-02-2010, 09:54 PM
  4. [Help]CheckBox[Solved]
    By ppl2pass in forum Visual Basic Programming
    Replies: 1
    Last Post: 03-07-2010, 10:54 PM