error C2228:

Discussion in 'C++' started by afg for life, Sep 10, 2010.

  1. afg for life

    afg for life New Member

    Joined:
    Sep 10, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hello everyone, i get this error when i try to run thsi program..its really nothing, i'm just a new programmer and this si practice but i'm stuck here :(
    error C2228: left of '.Text' must have class/struct/union
    1> type is 'System::Windows::Forms::Label ^'
    1> did you intend to use '->' instead?



    Code:
    #pragma once
    
    namespace HelloWorld1 {
    
    	using namespace System;
    	using namespace System::ComponentModel;
    	using namespace System::Collections;
    	using namespace System::Windows::Forms;
    	using namespace System::Data;
    	using namespace System::Drawing;
    
    	/// 
    	/// Summary for Form1
    	/// 
    	public ref class Form1 : public System::Windows::Forms::Form
    	{
    	public:
    		Form1(void)
    		{
    			InitializeComponent();
    			//
    			//TODO: Add the constructor code here
    			//
    		}
    
    	protected:
    		/// 
    		/// Clean up any resources being used.
    		/// 
    		~Form1()
    		{
    			if (components)
    			{
    				delete components;
    			}
    		}
    	private: System::Windows::Forms::Button^  Copy_Button;
    	protected: 
    	private: System::Windows::Forms::Label^  Answer_Label;
    	private: System::Windows::Forms::TextBox^  Data_Entry_Tb;
    
    	private:
    		/// 
    		/// Required designer variable.
    		/// 
    		System::ComponentModel::Container ^components;
    
    #pragma region Windows Form Designer generated code
    		/// 
    		/// Required method for Designer support - do not modify
    		/// the contents of this method with the code editor.
    		/// 
    		void InitializeComponent(void)
    		{
    			this->Copy_Button = (gcnew System::Windows::Forms::Button());
    			this->Answer_Label = (gcnew System::Windows::Forms::Label());
    			this->Data_Entry_Tb = (gcnew System::Windows::Forms::TextBox());
    			this->SuspendLayout();
    			// 
    			// Copy_Button
    			// 
    			this->Copy_Button->Location = System::Drawing::Point(49, 79);
    			this->Copy_Button->Name = L"Copy_Button";
    			this->Copy_Button->Size = System::Drawing::Size(161, 23);
    			this->Copy_Button->TabIndex = 0;
    			this->Copy_Button->Text = L"Copy to &Label ";
    			this->Copy_Button->UseVisualStyleBackColor = true;
    			this->Copy_Button->Click += gcnew System::EventHandler(this, &Form1::Copy_Button_Click);
    			// 
    			// Answer_Label
    			// 
    			this->Answer_Label->AutoSize = true;
    			this->Answer_Label->Font = (gcnew System::Drawing::Font(L"Book Antiqua", 18, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
    				static_cast(0)));
    			this->Answer_Label->Location = System::Drawing::Point(46, 147);
    			this->Answer_Label->Name = L"Answer_Label";
    			this->Answer_Label->Size = System::Drawing::Size(96, 28);
    			this->Answer_Label->TabIndex = 1;
    			this->Answer_Label->Text = L"Answer";
    			// 
    			// Data_Entry_Tb
    			// 
    			this->Data_Entry_Tb->Location = System::Drawing::Point(49, 8);
    			this->Data_Entry_Tb->Name = L"Data_Entry_Tb";
    			this->Data_Entry_Tb->Size = System::Drawing::Size(100, 20);
    			this->Data_Entry_Tb->TabIndex = 2;
    			this->Data_Entry_Tb->Text = L"TextBox1\t";
    			// 
    			// Form1
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(484, 262);
    			this->Controls->Add(this->Data_Entry_Tb);
    			this->Controls->Add(this->Answer_Label);
    			this->Controls->Add(this->Copy_Button);
    			this->Name = L"Form1";
    			this->Text = L"Hello World";
    			this->ResumeLayout(false);
    			this->PerformLayout();
    
    		}
    #pragma endregion
    	private: System::Void Copy_Button_Click(System::Object^  sender, System::EventArgs^  e) {Answer_Label.Text = Data_Entry_Tb.Text;}
    	};
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice