form1.h

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

H
184
字号
#pragma once


namespace treeView
{
	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::TreeView *  treeView1;
	private: System::Windows::Forms::CheckBox *  checkBox1;
	private: System::Windows::Forms::Button *  button1;
	private: System::Windows::Forms::Button *  button2;
	private: System::Windows::Forms::Button *  button3;
	private: System::Windows::Forms::TextBox *  textBox1;
	private: System::Windows::Forms::ToolTip *  toolTip1;
	private: System::ComponentModel::IContainer *  components;

	private:
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>


		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = new System::ComponentModel::Container();
			this->treeView1 = new System::Windows::Forms::TreeView();
			this->checkBox1 = new System::Windows::Forms::CheckBox();
			this->button1 = new System::Windows::Forms::Button();
			this->button2 = new System::Windows::Forms::Button();
			this->button3 = new System::Windows::Forms::Button();
			this->textBox1 = new System::Windows::Forms::TextBox();
			this->toolTip1 = new System::Windows::Forms::ToolTip(this->components);
			this->SuspendLayout();
			// 
			// treeView1
			// 
			this->treeView1->ImageIndex = -1;
			this->treeView1->Location = System::Drawing::Point(32, 24);
			this->treeView1->Name = S"treeView1";
			System::Windows::Forms::TreeNode* __mcTemp__1[] = new System::Windows::Forms::TreeNode*[1];
			System::Windows::Forms::TreeNode* __mcTemp__2[] = new System::Windows::Forms::TreeNode*[3];
			System::Windows::Forms::TreeNode* __mcTemp__3[] = new System::Windows::Forms::TreeNode*[5];
			__mcTemp__3[0] = new System::Windows::Forms::TreeNode(S"第1例 从Hello程序开始");
			__mcTemp__3[1] = new System::Windows::Forms::TreeNode(S"第2例 用消息对话框实现Hello程序");
			__mcTemp__3[2] = new System::Windows::Forms::TreeNode(S"第3例 用单文档实现Hello程序");
			__mcTemp__3[3] = new System::Windows::Forms::TreeNode(S"第4例 移动的文字");
			__mcTemp__3[4] = new System::Windows::Forms::TreeNode(S"第5例 椭圆窗体");
			__mcTemp__2[0] = new System::Windows::Forms::TreeNode(S"第一章 快速入门", __mcTemp__3);
			System::Windows::Forms::TreeNode* __mcTemp__4[] = new System::Windows::Forms::TreeNode*[3];
			__mcTemp__4[0] = new System::Windows::Forms::TreeNode(S"第6例 对话框");
			__mcTemp__4[1] = new System::Windows::Forms::TreeNode(S"第7例 按钮类控件");
			__mcTemp__4[2] = new System::Windows::Forms::TreeNode(S"第8例 列表框和组合框编程");
			__mcTemp__2[1] = new System::Windows::Forms::TreeNode(S"第2章 对话框和控件编程", __mcTemp__4);
			__mcTemp__2[2] = new System::Windows::Forms::TreeNode(S"第3章 图形图像处理");
			__mcTemp__1[0] = new System::Windows::Forms::TreeNode(S"Visual C++ .NET", __mcTemp__2);
			this->treeView1->Nodes->AddRange(__mcTemp__1);
			this->treeView1->SelectedImageIndex = -1;
			this->treeView1->Size = System::Drawing::Size(152, 192);
			this->treeView1->TabIndex = 0;
			// 
			// checkBox1
			// 
			this->checkBox1->Location = System::Drawing::Point(48, 224);
			this->checkBox1->Name = S"checkBox1";
			this->checkBox1->TabIndex = 1;
			this->checkBox1->Text = S"带复选框";
			this->toolTip1->SetToolTip(this->checkBox1, S"树形控件是否显示复选框");
			this->checkBox1->CheckedChanged += new System::EventHandler(this, cb_CheckedChanged);
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(216, 72);
			this->button1->Name = S"button1";
			this->button1->TabIndex = 2;
			this->button1->Text = S"增加";
			this->toolTip1->SetToolTip(this->button1, S"增加新的节点");
			this->button1->Click += new System::EventHandler(this, button1_Click);
			// 
			// button2
			// 
			this->button2->Location = System::Drawing::Point(216, 120);
			this->button2->Name = S"button2";
			this->button2->TabIndex = 3;
			this->button2->Text = S"删除";
			this->toolTip1->SetToolTip(this->button2, S"删除选中的节点");
			this->button2->Click += new System::EventHandler(this, button2_Click);
			// 
			// button3
			// 
			this->button3->Location = System::Drawing::Point(216, 168);
			this->button3->Name = S"button3";
			this->button3->TabIndex = 4;
			this->button3->Text = S"退出";
			this->toolTip1->SetToolTip(this->button3, S"退出应程序");
			this->button3->Click += new System::EventHandler(this, button3_Click);
			// 
			// textBox1
			// 
			this->textBox1->Location = System::Drawing::Point(200, 40);
			this->textBox1->Name = S"textBox1";
			this->textBox1->TabIndex = 5;
			this->textBox1->Text = S"新增节点";
			// 
			// Form1
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(320, 266);
			this->Controls->Add(this->textBox1);
			this->Controls->Add(this->button3);
			this->Controls->Add(this->button2);
			this->Controls->Add(this->button1);
			this->Controls->Add(this->checkBox1);
			this->Controls->Add(this->treeView1);
			this->Name = S"Form1";
			this->Text = S"treeView";
			this->ResumeLayout(false);

		}	
	private: System::Void cb_CheckedChanged(System::Object *  sender, System::EventArgs *  e)
			 {
				 if(checkBox1->Checked )
					 treeView1->CheckBoxes = true;
				 else
					 treeView1->CheckBoxes = false;
			 }

	private: System::Void button2_Click(System::Object *  sender, System::EventArgs *  e)
			 {
				 treeView1->Nodes->Remove(treeView1->SelectedNode);
			 }

private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 TreeNode *tNode = new TreeNode();
			 tNode->Text = textBox1->Text ;
			 treeView1->SelectedNode->Nodes->Add (tNode);

		 }

private: System::Void button3_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 this->Close();
		 }

};
}


⌨️ 快捷键说明

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