Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 416893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:31:33+00:00 2026-05-12T18:31:33+00:00

trying to run this basic form control example on msdn. At step 1 of

  • 0

trying to run this basic form control example on msdn.

At step 1 of the portion “To add a custom property to a control” we place the ClickAnywhere code in the public section of the class.

First error: “error C2144: syntax error : ‘bool’ should be preceded by ‘;’”

Is this syntax correct in C++? (see below)
(removing the ClickAnywhere portion of code, it compiles fine…)

#pragma once

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


namespace clickcounter
{
    /// <summary> 
    /// Summary for clickcounterControl
    /// </summary>
    ///
    /// WARNING: If you change the name of this class, you will need to change the 
    ///          'Resource File Name' property for the managed resource compiler tool 
    ///          associated with all .resx files this class depends on.  Otherwise,
    ///          the designers will not be able to interact properly with localized
    ///          resources associated with this form.
    public __gc class clickcounterControl : public System::Windows::Forms::UserControl
    {   
    public:



//Problem code*****  


property bool ClickAnywhere { //Is this syntax right in C++?
    bool get() {
        return (label1->Dock == DockStyle::Fill);
    }
    void set(bool val) {
        if (val) 
            label1->Dock = DockStyle::Fill;
        else 
            label1->Dock = DockStyle::None;
    }
}
//End Problem code***** 


        clickcounterControl(void)   
        {
            InitializeComponent();
        }



    protected:
        void Dispose(Boolean disposing) 
        {
            if (disposing && components)
            {
                components->Dispose();
            }
            __super::Dispose(disposing);
        }
    private: System::Windows::Forms::Label *  label1;

    private:
        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::Container* components;

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        void InitializeComponent(void)
        {
            this->label1 = new System::Windows::Forms::Label();
            this->SuspendLayout();
            // 
            // label1
            // 
            this->label1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
            this->label1->Location = System::Drawing::Point(32, 40);
            this->label1->Name = S"label1";
            this->label1->Size = System::Drawing::Size(30, 20);
            this->label1->TabIndex = 0;
            this->label1->Text = S"0";
            this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
            this->label1->Click += new System::EventHandler(this, label1_Click);
            // 
            // clickcounterControl
            // 
            this->Controls->Add(this->label1);
            this->Name = S"clickcounterControl";
            this->Size = System::Drawing::Size(100, 100);
            this->ResumeLayout(false);

        }
    private: System::Void label1_Click(System::Object *  sender, System::EventArgs *  e)
             {
                int temp = System::Int32::Parse(label1->Text);
                temp++;
                label1->Text = temp.ToString();
             }

    };
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:31:33+00:00Added an answer on May 12, 2026 at 6:31 pm

    Since you are using Visual Studio .Net 2003, you are using Managed C++, not C++/CLI. There is a significant difference in syntax. For a property, you must use the __property keyword, not the C++/CLI property keyword and its new style.

    It should therefore be:

    __property bool get_ClickAnywhere() {
        return (label1->Dock == DockStyle::Fill);
    }
    __property void set_ClickAnywhere(bool value) {
        if (value)
            label1->Dock = DockStyle::Fill;
        else 
            label1->Dock = DockStyle::None;
    }
    

    It looks like you are being tripped up by following a guide written for C++/CLI (Visual Studio 2005 and later) while still using Visual Studio 2003.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 202k
  • Answers 202k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer See http://code.google.com/p/oauth-signpost/ May 12, 2026 at 8:25 pm
  • Editorial Team
    Editorial Team added an answer The problem is solved. Basically in the handleMessage method, don't… May 12, 2026 at 8:25 pm
  • Editorial Team
    Editorial Team added an answer If it's not the same as the referred to question… May 12, 2026 at 8:25 pm

Related Questions

I'm currently writing some methods that do some basic operations on form controls eg
I'm new to Prism and I am attempting to host a Prisim control within
I've been trying to build a simple prototype application in Django, and am reaching
Background: I'm using WPF and C# (3.5) and am working on an app that
I'm trying to create a web user interface for a Java application. The user

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.