Click to See Complete Forum and Search --> : Check Box


nerrazzuri
May 28th, 2010, 11:53 AM
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.

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.

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.

Alex F
May 29th, 2010, 05:04 AM
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.

nerrazzuri
May 29th, 2010, 02:27 PM
Thanks for the reply, I think I get the solution already, I was totally my fault. Anyway, thanks.