CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Check Box

  1. #1
    Join Date
    May 2010
    Posts
    13

    Check Box

    I'm currently learning how to add in a checkbox for a windows form. This was the example of checkbox codes to activate the main.cpp codes.

    Code:
    private:
       void checkBox1_CheckedChanged(System::Object ^ sender, System::EventArgs ^ e)
       {
          if (checkBox1->Checked)
          {
             checkBox1->Text = "Checked";
          }
          else
          {
             checkBox1->Text = "Unchecked";
          }
       }
    But when I compile it, this is my error.

    Code:
    error C2059: syntax error : 'private'
    error C2227: left of '->Checked' must point to class/struct/union/generic type
              type is ''int''
    error C2227: left of '->Text' must point to class/struct/union/generic type
              type is ''int''
    error C2227: left of '->Text' must point to class/struct/union/generic type
              type is ''int''
    Why is that 'private' has syntax error? And what is the class/struct/union/generic type mean?

    Thanks in advance.

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Check Box

    It is impossible to say why C2059 is printed, without looking the whole h-file. C2227 is printed because there is no checkBox1 class member. Post the whole code to see what happens.

  3. #3
    Join Date
    May 2010
    Posts
    13

    Re: Check Box

    Thanks for the reply, I think I get the solution already, I was totally my fault. Anyway, thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured