📄 form1.h
字号:
#pragma once
namespace Example {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Globalization;
/// <summary>
/// Form1 摘要
///
/// 警告: 如果更改此类的名称,则需要更改
/// 与此类所依赖的所有 .resx 文件关联的托管资源编译器工具的
/// “资源文件名”属性。否则,
/// 设计器将不能与此窗体的关联
/// 本地化资源正确交互。
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: 在此处添加构造函数代码
//
}
protected:
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ label1;
protected:
private: System::Windows::Forms::ListBox^ listBox1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::PropertyGrid^ propertyGrid1;
private:
/// <summary>
/// 必需的设计器变量。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
void InitializeComponent(void)
{
this->label1 = (gcnew System::Windows::Forms::Label());
this->listBox1 = (gcnew System::Windows::Forms::ListBox());
this->label2 = (gcnew System::Windows::Forms::Label());
this->propertyGrid1 = (gcnew System::Windows::Forms::PropertyGrid());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(2, 4);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(77, 12);
this->label1->TabIndex = 0;
this->label1->Text = L"请选择文化:";
//
// listBox1
//
this->listBox1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left));
this->listBox1->FormattingEnabled = true;
this->listBox1->ItemHeight = 12;
this->listBox1->Location = System::Drawing::Point(4, 20);
this->listBox1->Name = L"listBox1";
this->listBox1->Size = System::Drawing::Size(75, 184);
this->listBox1->TabIndex = 1;
this->listBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::listBox1_SelectedIndexChanged);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(85, 4);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(173, 12);
this->label2->TabIndex = 2;
this->label2->Text = L"显示当前选择文化的详细信息:";
//
// propertyGrid1
//
this->propertyGrid1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->propertyGrid1->Location = System::Drawing::Point(86, 20);
this->propertyGrid1->Name = L"propertyGrid1";
this->propertyGrid1->Size = System::Drawing::Size(303, 184);
this->propertyGrid1->TabIndex = 3;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(390, 207);
this->Controls->Add(this->propertyGrid1);
this->Controls->Add(this->label2);
this->Controls->Add(this->listBox1);
this->Controls->Add(this->label1);
this->Name = L"Form1";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"演示获取文化属性信息";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
public:array<CultureInfo^>^ MyAllCultures;
//获取当前系统已经安装的所有文化
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
this->MyAllCultures=CultureInfo::GetCultures(CultureTypes::AllCultures);
this->listBox1->DataSource=this->MyAllCultures;
}
//显示当前选择文化的详细信息
private: System::Void listBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
int MyIndex=this->listBox1->SelectedIndex;
this->label2->Text=this->listBox1->Text+"文化的详细信息如下 :";
this->propertyGrid1->SelectedObject=this->MyAllCultures[MyIndex];
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -