G
Geoff Cox
Hello,
Can I separately declare and initialize a string array? How and where
would I do it in the code below? It was created using Visual C++ 2005
Express Beta 2 ...
In C# I would have
private string[] myArray;
and later
myArray = new string[] {"element 1","element 2"};
Now, I know C++ is more difficult to learn than C# but .......
Thanks
Geoff
#pragma once
namespace slider1
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System:ata;
using namespace System:rawing;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">"description of the
parameter"</param>
virtual void Dispose(Boolean disposing) override
{
if (disposing && components)
{
delete components;
}
__super:ispose(disposing);
}
private: System::Windows::Forms:ictureBox^ pictureBox1;
protected:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::TrackBar^ trackBar1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not
modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew
System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->pictureBox1 = (gcnew
System::Windows::Forms:ictureBox());
this->button1 = (gcnew
System::Windows::Forms::Button());
this->label1 = (gcnew
System::Windows::Forms::Label());
this->label2 = (gcnew
System::Windows::Forms::Label());
this->trackBar1 = (gcnew
System::Windows::Forms::TrackBar());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^
//
// pictureBox1
//
this->pictureBox1->Image =
(cli::safe_cast<System:rawing::Image^
System:rawing:oint(36, 26);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size =
System:rawing::Size(218, 129);
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
//
// button1
//
this->button1->Location =
System:rawing:oint(105, 231);
this->button1->Name = L"button1";
this->button1->Size =
System:rawing::Size(75, 23);
this->button1->TabIndex = 1;
this->button1->Text = L"button1";
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location =
System:rawing:oint(23, 190);
this->label1->Name = L"label1";
this->label1->Size = System:rawing::Size(31,
13);
this->label1->TabIndex = 2;
this->label1->Text = L"label1";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location =
System:rawing:oint(222, 190);
this->label2->Name = L"label2";
this->label2->Size = System:rawing::Size(31,
13);
this->label2->TabIndex = 3;
this->label2->Text = L"label2";
//
// trackBar1
//
this->trackBar1->Location =
System:rawing:oint(87, 180);
this->trackBar1->Name = L"trackBar1";
this->trackBar1->Size =
System:rawing::Size(104, 45);
this->trackBar1->TabIndex = 4;
this->trackBar1->Scroll += gcnew
System::EventHandler(this, &Form1::Form1_Load);
//
// Form1
//
this->AutoScaleDimensions =
System:rawing::SizeF(6, 13);
this->AutoScaleMode =
System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System:rawing::Size(292,
266);
this->Controls->Add(this->trackBar1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->button1);
this->Controls->Add(this->pictureBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this,
&Form1::Form1_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^
this->PerformLayout();
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e) {
}
};
}
Can I separately declare and initialize a string array? How and where
would I do it in the code below? It was created using Visual C++ 2005
Express Beta 2 ...
In C# I would have
private string[] myArray;
and later
myArray = new string[] {"element 1","element 2"};
Now, I know C++ is more difficult to learn than C# but .......
Thanks
Geoff
#pragma once
namespace slider1
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System:ata;
using namespace System:rawing;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">"description of the
parameter"</param>
virtual void Dispose(Boolean disposing) override
{
if (disposing && components)
{
delete components;
}
__super:ispose(disposing);
}
private: System::Windows::Forms:ictureBox^ pictureBox1;
protected:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::TrackBar^ trackBar1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not
modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew
System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->pictureBox1 = (gcnew
System::Windows::Forms:ictureBox());
this->button1 = (gcnew
System::Windows::Forms::Button());
this->label1 = (gcnew
System::Windows::Forms::Label());
this->label2 = (gcnew
System::Windows::Forms::Label());
this->trackBar1 = (gcnew
System::Windows::Forms::TrackBar());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^
this->SuspendLayout();(this->pictureBox1))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^
(this->trackBar1))->BeginInit();
//
// pictureBox1
//
this->pictureBox1->Image =
(cli::safe_cast<System:rawing::Image^
this->pictureBox1->Location =(resources->GetObject(L"pictureBox1.Image")));
System:rawing:oint(36, 26);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size =
System:rawing::Size(218, 129);
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
//
// button1
//
this->button1->Location =
System:rawing:oint(105, 231);
this->button1->Name = L"button1";
this->button1->Size =
System:rawing::Size(75, 23);
this->button1->TabIndex = 1;
this->button1->Text = L"button1";
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location =
System:rawing:oint(23, 190);
this->label1->Name = L"label1";
this->label1->Size = System:rawing::Size(31,
13);
this->label1->TabIndex = 2;
this->label1->Text = L"label1";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location =
System:rawing:oint(222, 190);
this->label2->Name = L"label2";
this->label2->Size = System:rawing::Size(31,
13);
this->label2->TabIndex = 3;
this->label2->Text = L"label2";
//
// trackBar1
//
this->trackBar1->Location =
System:rawing:oint(87, 180);
this->trackBar1->Name = L"trackBar1";
this->trackBar1->Size =
System:rawing::Size(104, 45);
this->trackBar1->TabIndex = 4;
this->trackBar1->Scroll += gcnew
System::EventHandler(this, &Form1::Form1_Load);
//
// Form1
//
this->AutoScaleDimensions =
System:rawing::SizeF(6, 13);
this->AutoScaleMode =
System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System:rawing::Size(292,
266);
this->Controls->Add(this->trackBar1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->button1);
this->Controls->Add(this->pictureBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this,
&Form1::Form1_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^
this->ResumeLayout(false);(this->pictureBox1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^
(this->trackBar1))->EndInit();
this->PerformLayout();
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e) {
}
};
}