Davy
Davy

Reputation: 23

Visual c++ Form - How to change the visible properties of a label through a button click?

So this is the first time I've attempted to change the visible properties of objects in forms and I've run into some problems. I was hoping someone here could offer some insight. Essentially what i'm trying to do is create a Quiz game where the user is given a question and then provided with four possible answers, upon clicking one of these four buttons I want a label to appear indicating whether that was the correct or incorrect answer.

I have a label where I've set its visibility to false, and then through my button's event I want to change the visibility to true.

I attempted this through this line of code in the button's event:

    private: System::Void Answer1_Click(System::Object^  sender, System::EventArgs^  e) {
        label2.Visible = true

    }

Evidently this doesn't work.

Any ideas why?

Upvotes: 1

Views: 1321

Answers (1)

Davy
Davy

Reputation: 23

I feel like a total donkey, I was writing in Visual Basic! The proper code would be label2->Visible = true; instead of label2.Visible = true. I hope this can help someone.

Upvotes: 1

Related Questions