⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 7.3.txt

📁 《Microsoft Visual C# .NET 2003开发技巧大全》源代码
💻 TXT
字号:
Listing 7.3 Changing MDI Child Title Bars
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;
namespace _12_MDIChild
{
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
ChildForm[] childForms = new ChildForm[3];
public Form1()
{
InitializeComponent();
for( int i = 0; i < 3; i++ )
{
childForms[i] = new ChildForm();
childForms[i].MdiParent = this;
childForms[i].Show();
}
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.IsMdiContainer = true;
this.Name = “Form1”;
this.Text = “Form1”;
this.MdiChildActivate +=
new System.EventHandler(this.Form1_MdiChildActivate);
}
#endregion
private void Form1_MdiChildActivate(object sender, System.EventArgs e)
{
StringBuilder childTitle = new StringBuilder();
foreach( Form child in this.MdiChildren )
{
childTitle.Append(child.Text);
childTitle.Replace( “- Active”, “” );
if( this.ActiveMdiChild == child )
{
child.ActiveControl.Text = “Active Child”;
child.Text = childTitle.ToString() + “- Active”;
}
else
{
child.Controls[0].Text = “Not Active Child”;
child.Text = childTitle.ToString();
}
childTitle.Remove(0, childTitle.Length);
}
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}

⌨️ 快捷键说明

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