|
![]() | 作者: xiaoshi [xiaoshi]
![]() |
登录 |
源代码 ********* using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace ch1_9 { /// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.GroupBox groupBox3; private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.CheckBox checkBox1; private System.Windows.Forms.CheckBox checkBox2; private System.Windows.Forms.CheckBox checkBox3; private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.TabPage tabPage3; /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.checkBox1 = new System.Windows.Forms.CheckBox(); this.checkBox2 = new System.Windows.Forms.CheckBox(); this.checkBox3 = new System.Windows.Forms.CheckBox(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage3 = new System.Windows.Forms.TabPage(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); this.tabControl1.SuspendLayout(); this.SuspendLayout(); // // groupBox1 // this.groupBox1.Controls.Add(this.tabControl1); this.groupBox1.Controls.Add(this.groupBox3); this.groupBox1.Controls.Add(this.groupBox2); this.groupBox1.Location = new System.Drawing.Point(24, 8); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(472, 488); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; // // groupBox2 // this.groupBox2.Controls.Add(this.button2); this.groupBox2.Controls.Add(this.button1); this.groupBox2.Controls.Add(this.textBox1); this.groupBox2.Controls.Add(this.label2); this.groupBox2.Controls.Add(this.label1); this.groupBox2.Location = new System.Drawing.Point(24, 200); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(424, 136); this.groupBox2.TabIndex = 0; this.groupBox2.TabStop = false; this.groupBox2.Text = "添加删除选项卡"; // // groupBox3 // this.groupBox3.Controls.Add(this.checkBox3); this.groupBox3.Controls.Add(this.checkBox2); this.groupBox3.Controls.Add(this.checkBox1); this.groupBox3.Controls.Add(this.comboBox1); this.groupBox3.Controls.Add(this.button3); this.groupBox3.Controls.Add(this.label4); this.groupBox3.Controls.Add(this.label3); this.groupBox3.Location = new System.Drawing.Point(24, 352); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(424, 128); this.groupBox3.TabIndex = 1; this.groupBox3.TabStop = false; this.groupBox3.Text = "TabControl设置"; // // tabControl1 // this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Location = new System.Drawing.Point(24, 80); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; this.tabControl1.Size = new System.Drawing.Size(424, 100); this.tabControl1.TabIndex = 2; // // label1 // this.label1.Location = new System.Drawing.Point(24, 40); this.label1.Name = "label1"; this.label1.TabIndex = 0; this.label1.Text = "添加一个选项卡"; // // label2 // this.label2.Location = new System.Drawing.Point(16, 88); this.label2.Name = "label2"; this.label2.TabIndex = 1; this.label2.Text = "删除一个选项卡"; // // label3 // this.label3.Location = new System.Drawing.Point(16, 32); this.label3.Name = "label3"; this.label3.TabIndex = 0; this.label3.Text = "选项卡按钮外观"; // // label4 // this.label4.Location = new System.Drawing.Point(16, 72); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(96, 32); this.label4.TabIndex = 1; this.label4.Text = "是否多行显示选项卡"; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(160, 40); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(128, 21); this.textBox1.TabIndex = 2; this.textBox1.Text = ""; // // button1 // this.button1.Location = new System.Drawing.Point(336, 40); this.button1.Name = "button1"; this.button1.TabIndex = 3; this.button1.Text = "确定"; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(336, 80); this.button2.Name = "button2"; this.button2.TabIndex = 4; this.button2.Text = "确定"; this.button2.Click += new System.EventHandler(this.button2_Click); // // button3 // this.button3.Location = new System.Drawing.Point(296, 88); this.button3.Name = "button3"; this.button3.TabIndex = 2; this.button3.Text = "确定"; this.button3.Click += new System.EventHandler(this.button3_Click); // // comboBox1 // this.comboBox1.Items.AddRange(new object[] { "Normal, Buttons, FlatButtons"}); this.comboBox1.Location = new System.Drawing.Point(232, 32); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(121, 20); this.comboBox1.TabIndex = 3; this.comboBox1.Text = "Normal"; // // checkBox1 // this.checkBox1.Location = new System.Drawing.Point(240, 64); this.checkBox1.Name = "checkBox1"; this.checkBox1.TabIndex = 4; this.checkBox1.Text = "是"; this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); // // checkBox2 // this.checkBox2.Location = new System.Drawing.Point(328, 64); this.checkBox2.Name = "checkBox2"; this.checkBox2.TabIndex = 5; this.checkBox2.Text = "否"; // // checkBox3 // this.checkBox3.Location = new System.Drawing.Point(136, 80); this.checkBox3.Name = "checkBox3"; this.checkBox3.TabIndex = 6; this.checkBox3.Text = "HotTrack"; // // tabPage1 // this.tabPage1.Location = new System.Drawing.Point(4, 21); this.tabPage1.Name = "tabPage1"; this.tabPage1.Size = new System.Drawing.Size(416, 75); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "tabPage1"; // // tabPage2 // this.tabPage2.Location = new System.Drawing.Point(4, 21); this.tabPage2.Name = "tabPage2"; this.tabPage2.Size = new System.Drawing.Size(416, 75); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "tabPage2"; // // tabPage3 // this.tabPage3.Location = new System.Drawing.Point(4, 21); this.tabPage3.Name = "tabPage3"; this.tabPage3.Size = new System.Drawing.Size(416, 75); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "tabPage3"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(520, 509); this.Controls.Add(this.groupBox1); this.Name = "Form1"; this.Text = "TabControl实例"; this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.groupBox3.ResumeLayout(false); this.tabControl1.ResumeLayout(false); this.ResumeLayout(false); } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } private void button1_Click(object sender, System.EventArgs e) { string tabpagename = textBox1.Text; //如果textbox里面没有输入,则发出一个警告 if ( tabpagename =="" ) { MessageBox.Show("请输入选项卡名称","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning); } else { //新建一个tabpage类的实例 TabPage newtabpage=new TabPage(tabpagename); //添加一个新的选项卡 tabControl1.TabPages.Add(newtabpage); } } private void button2_Click(object sender, System.EventArgs e) { //删除当前选项卡 tabControl1.TabPages.Remove(tabControl1.SelectedTab); } private void checkBox1_CheckedChanged(object sender, System.EventArgs e) { //保证只能选一个checkbox if (checkBox1.Checked == true) { checkBox1.Checked=false; } } private void button3_Click(object sender, System.EventArgs e) { //设置选项卡是否多行显示 if (checkBox3.Checked == true) { tabControl1.Multiline=true; } else { tabControl1.Multiline=false; } //选择选项卡外观 switch (comboBox1.SelectedItem.ToString()) { case "Normal": tabControl1.Appearance=Tabappearance.Normal; break; case "FlatButtons": tabControl1.Appearance=Tabappearance.FlatButtons; break; case "Buttons": tabControl1.Appearance=Tabappearance.Buttons; break; } //设置HotTrack选项 tabControl1.HotTrack=checkBox3.Checked; } } } 提示错误 ************* E:\98\ch1_9\Form1.cs(340): 找不到类型或命名空间名称“Tabappearance”(是否缺少 using 指令或程序集引用?) E:\98\ch1_9\Form1.cs(343): 找不到类型或命名空间名称“Tabappearance”(是否缺少 using 指令或程序集引用?) E:\98\ch1_9\Form1.cs(337): 找不到类型或命名空间名称“Tabappearance”(是否缺少 using 指令或程序集引用?) |
地主 发表时间: 04-06-13 10:09 |
![]() | 回复: ziaichen [ziaichen] ![]() |
登录 |
看了半天也不明白 我帮你顶! |
B1层 发表时间: 04-06-13 14:42 |
![]() | 回复: xiaoshi [xiaoshi] ![]() |
登录 |
呜呜~~~~~~~~![]() ![]() ![]() |
B2层 发表时间: 04-06-13 15:21 |
![]() | 回复: moonsl [moonsl] ![]() |
登录 |
帮你加生望吧 |
B3层 发表时间: 04-06-15 13:33 |
![]() | 回复: xiaoshi [xiaoshi] ![]() |
登录 |
286有时间指教吗? 先谢过了! |
B4层 发表时间: 04-06-15 18:49 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号