form1.h

来自「Visual_C++.NET实用编程百例」· C头文件 代码 · 共 195 行

H
195
字号
#pragma once


namespace listView
{
	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> 
	/// Form1 摘要
	///
	/// 警告: 如果您更改该类的名称,则需要更改 
	///          与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的 
	///          “资源文件名”属性。  否则,
	///          设计器将不能与此窗体关联的
	///          本地化资源正确交互。
	/// </summary>
	public __gc class Form1 : public System::Windows::Forms::Form
	{	
	public:
		Form1(void)
		{
			InitializeComponent();
		}
  
	protected:
		void Dispose(Boolean disposing)
		{
			if (disposing && components)
			{
				components->Dispose();
			}
			__super::Dispose(disposing);
		}
	private: System::Windows::Forms::Label *  label1;
	private: System::Windows::Forms::Label *  label2;
	private: System::Windows::Forms::Label *  label3;
	private: System::Windows::Forms::TextBox *  textBox1;
	private: System::Windows::Forms::TextBox *  textBox2;
	private: System::Windows::Forms::TextBox *  textBox3;
	private: System::Windows::Forms::Button *  button1;
	private: System::Windows::Forms::ListView *  listView1;
	private: System::Windows::Forms::ColumnHeader* columnHeader1;
	private: System::Windows::Forms::ColumnHeader* columnHeader2;
	private: System::Windows::Forms::ColumnHeader* columnHeader3;

	private:
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		System::ComponentModel::Container * components;

		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			this->label1 = new System::Windows::Forms::Label();
			this->label2 = new System::Windows::Forms::Label();
			this->label3 = new System::Windows::Forms::Label();
			this->textBox1 = new System::Windows::Forms::TextBox();
			this->textBox2 = new System::Windows::Forms::TextBox();
			this->textBox3 = new System::Windows::Forms::TextBox();
			this->button1 = new System::Windows::Forms::Button();
			this->listView1 = new System::Windows::Forms::ListView();
			this->SuspendLayout();
			// 
			// label1
			// 
			this->label1->Location = System::Drawing::Point(240, 32);
			this->label1->Name = S"label1";
			this->label1->Size = System::Drawing::Size(40, 23);
			this->label1->TabIndex = 0;
			this->label1->Text = S"学号";
			// 
			// label2
			// 
			this->label2->Location = System::Drawing::Point(240, 72);
			this->label2->Name = S"label2";
			this->label2->Size = System::Drawing::Size(40, 23);
			this->label2->TabIndex = 1;
			this->label2->Text = S"姓名";
			// 
			// label3
			// 
			this->label3->Location = System::Drawing::Point(240, 104);
			this->label3->Name = S"label3";
			this->label3->Size = System::Drawing::Size(40, 23);
			this->label3->TabIndex = 2;
			this->label3->Text = S"年龄";
			// 
			// textBox1
			// 
			this->textBox1->Location = System::Drawing::Point(288, 32);
			this->textBox1->Name = S"textBox1";
			this->textBox1->TabIndex = 3;
			this->textBox1->Text = S"";
			// 
			// textBox2
			// 
			this->textBox2->Location = System::Drawing::Point(288, 72);
			this->textBox2->Name = S"textBox2";
			this->textBox2->TabIndex = 4;
			this->textBox2->Text = S"";
			// 
			// textBox3
			// 
			this->textBox3->Location = System::Drawing::Point(288, 104);
			this->textBox3->Name = S"textBox3";
			this->textBox3->TabIndex = 5;
			this->textBox3->Text = S"";
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(280, 176);
			this->button1->Name = S"button1";
			this->button1->TabIndex = 6;
			this->button1->Text = S"添加";
			this->button1->Click += new System::EventHandler(this, button1_Click);
			// 
			// listView1
			// 
			this->listView1->Location = System::Drawing::Point(24, 16);
			this->listView1->Name = S"listView1";
			this->listView1->Size = System::Drawing::Size(200, 192);
			this->listView1->TabIndex = 7;
			this->listView1->View = System::Windows::Forms::View::Details;
			// 
			// Form1
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(416, 238);
			this->Controls->Add(this->listView1);
			this->Controls->Add(this->button1);
			this->Controls->Add(this->textBox3);
			this->Controls->Add(this->textBox2);
			this->Controls->Add(this->textBox1);
			this->Controls->Add(this->label3);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->label1);
			this->Name = S"Form1";
			this->Text = S"学生列表";
			this->Load += new System::EventHandler(this, Form1_Load);
			this->ResumeLayout(false);

		}	
	private: System::Void Form1_Load(System::Object *  sender, System::EventArgs *  e)
			 {
				 columnHeader1 = new ColumnHeader();
				 columnHeader2 = new ColumnHeader();
				 columnHeader3 = new ColumnHeader();
				 columnHeader1->Text = "学号";
				 columnHeader2->Text = "姓名";
				 columnHeader3->Text = "年龄";
				 ColumnHeader* col[] = new ColumnHeader*[3];
				 col[0] = columnHeader1;
				 col[1] = columnHeader2;
				 col[2] = columnHeader3;
				 listView1->Columns->AddRange(col);
				 String * strTmp[] = new String *[3];
				 strTmp[0] = S"01";
				 strTmp[1] = S"张敏";
				 strTmp[2] = S"25";
				 ListViewItem *item1 = new ListViewItem(strTmp);
				 strTmp[0] = S"02";
				 strTmp[1] = S"张艳玲";
				 strTmp[2] = S"22";
				 ListViewItem *item2 = new ListViewItem(strTmp);
				 ListViewItem* item[] = new ListViewItem*[2];
				 item[0] = item1;
				 item[1] = item2;
				 listView1->Items->AddRange(item);
			 }
	private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e)
			 {
				 String * strTmp[] = new String *[3];
				 strTmp[0] = textBox1->Text;
				 strTmp[1] = textBox2->Text;
				 strTmp[2] = textBox3->Text;
				 ListViewItem *item1 = new ListViewItem(strTmp);
				 ListViewItem *i[] = new ListViewItem* [1];
				 i[0] = item1;
				 listView1->Items->AddRange(i);
			 }

};
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?