How to Create Array of Labels on the Run-Time ?
-
How to Create Array of Labels on the Run-Time ? Best Regards...
-
How to Create Array of Labels on the Run-Time ? Best Regards...
-
Hello, if you mean with "Label" a System::Windows::Forms::Label control then you could use this snippet: // an array of 10 Labels array myLabelArray = gcnew array(10); regards Tobias
I try but error occur error C3149: 'cli::array' : cannot use this type here without a top-level '^'
-
I try but error occur error C3149: 'cli::array' : cannot use this type here without a top-level '^'
-
Sorry my fault, my thoughts were faster than my fingers: (I forgot the '^' hat operator which classifies myLabelArray as a reference type) array^ myLabelArray = gcnew array(10); Tobias
Thanks your help. array^ myLabelArray = gcnew array(10); //Its work But myLabelArray[0]->Location = Point(100,100); //NOT WORK :confused:
-
Thanks your help. array^ myLabelArray = gcnew array(10); //Its work But myLabelArray[0]->Location = Point(100,100); //NOT WORK :confused:
Hi, maybe my first statement lead you in the wrong direction. array^ myLabelArray = gcnew array(10); This line just creates an array with 10 references of the type Label. A reference type is implicitly initialized with a nullptr, thus myLabelArray[0]->Location = Point(100,100); will not work unless you initialize it first. // will work lab[0] = gcnew Label(); lab[0]->Location = Point(10,10); You should also use try-catch to catch exceptions that possibly occur. regards Tobias
-
Hi, maybe my first statement lead you in the wrong direction. array^ myLabelArray = gcnew array(10); This line just creates an array with 10 references of the type Label. A reference type is implicitly initialized with a nullptr, thus myLabelArray[0]->Location = Point(100,100); will not work unless you initialize it first. // will work lab[0] = gcnew Label(); lab[0]->Location = Point(10,10); You should also use try-catch to catch exceptions that possibly occur. regards Tobias
No Error Occur But I Can't See Label on the Form array^ myLabelArray = gcnew array(10); myLabelArray[0] = gcnew Label(); myLabelArray[0]->AutoSize = true; myLabelArray[0]->Location = System::Drawing::Point(100, 10); myLabelArray[0]->Name = L"lblX"; myLabelArray[0]->Size = System::Drawing::Size(63, 13); myLabelArray[0]->Text = "HELLO"; myLabelArray[0]->TabIndex = 50; myLabelArray[0]->Visible = true; :sigh: Best Regards
-
No Error Occur But I Can't See Label on the Form array^ myLabelArray = gcnew array(10); myLabelArray[0] = gcnew Label(); myLabelArray[0]->AutoSize = true; myLabelArray[0]->Location = System::Drawing::Point(100, 10); myLabelArray[0]->Name = L"lblX"; myLabelArray[0]->Size = System::Drawing::Size(63, 13); myLabelArray[0]->Text = "HELLO"; myLabelArray[0]->TabIndex = 50; myLabelArray[0]->Visible = true; :sigh: Best Regards
Hi, you forgot to add the label to the form. private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { array^ myLabelArray = gcnew array(10); myLabelArray[0] = gcnew Label(); myLabelArray[0]->AutoSize = true; myLabelArray[0]->Location = System::Drawing::Point(100, 10); myLabelArray[0]->Name = L"lblX"; myLabelArray[0]->Size = System::Drawing::Size(63, 13); myLabelArray[0]->Text = "HELLO"; myLabelArray[0]->TabIndex = 50; myLabelArray[0]->Visible = true; this->Controls->Add(myLabelArray[0]); } }; regards Tobias
-
Hi, you forgot to add the label to the form. private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { array^ myLabelArray = gcnew array(10); myLabelArray[0] = gcnew Label(); myLabelArray[0]->AutoSize = true; myLabelArray[0]->Location = System::Drawing::Point(100, 10); myLabelArray[0]->Name = L"lblX"; myLabelArray[0]->Size = System::Drawing::Size(63, 13); myLabelArray[0]->Text = "HELLO"; myLabelArray[0]->TabIndex = 50; myLabelArray[0]->Visible = true; this->Controls->Add(myLabelArray[0]); } }; regards Tobias
It's work, thanks a lot 2bee... :-D