using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace aa
{
/// <summary>
/// Form1 的摘要描述。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
object[] btnObject=new object[3];
private System.Windows.Forms.ImageList imageList1;
private System.ComponentModel.IContainer components; public Form1()
{
//
// Windows Form 設計工具支援的必要項
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 呼叫之後加入任何建構函式程式碼
//
} /// <summary>
/// 清除任何使用中的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null) 
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form 設計工具產生的程式碼
/// <summary>
/// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.SuspendLayout();
// 
// button1
// 
this.button1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("button1.BackgroundImage")));
this.button1.Location = new System.Drawing.Point(72, 40);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
// 
// button2
// 
this.button2.Location = new System.Drawing.Point(72, 104);
this.button2.Name = "button2";
this.button2.TabIndex = 1;
this.button2.Text = "button2";
this.button2.Click += new System.EventHandler(this.button1_Click);
// 
// button3
// 
this.button3.Location = new System.Drawing.Point(72, 168);
this.button3.Name = "button3";
this.button3.TabIndex = 2;
this.button3.Text = "button3";
this.button3.Click += new System.EventHandler(this.button1_Click);
// 
// imageList1
// 
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
// 
// Form1
// 
this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
this.ClientSize = new System.Drawing.Size(440, 273);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false); }
#endregion /// <summary>
/// 應用程式的主進入點。
/// </summary>
[STAThread]
static void Main() 
{
Application.Run(new Form1());
} private void Form1_Load(object sender, System.EventArgs e)
{
btnObject[0]=this.button1;
btnObject[1]=this.button2;
btnObject[2]=this.button3;
} private void button1_Click(object sender, System.EventArgs e)
{
//圖片自己設置
Button obj=sender as Button;
if(obj.FlatStyle!=FlatStyle.Flat)
{
obj.FlatStyle=FlatStyle.Flat;
// obj.BackgroundImage=imageList1.Images[0];
foreach(object btn in btnObject)
{
Button tmpButton=btn as Button;
if(tmpButton.Name!=obj.Name)
{
tmpButton.FlatStyle=FlatStyle.Standard;
// obj.BackgroundImage=imageList1.Images[1];
}
}
}
}
}
}