標籤:private 圖片 public 風格
19.按鈕控制項
1.常用的屬性。
a.Text屬性。該屬性設定在按鈕上顯示文本。
b.FlatStyle屬性。該屬性指定按鈕的外觀風格。
c.Image屬性。該屬性指定在按鈕上顯示圖形。
d.ImageAlign屬性。該屬性可以調節圖片在按鈕上的位置。
e.Enable屬性。該屬性是否可用,不可用則用灰色表示。
f.Visiable屬性。該屬性是否可見,不可見則隱藏。
在加上視窗的單擊,載入,關閉等事件,如下。
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
private int ncount = 50;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.ncount = 50;
this.ShowCounter();
this.BackColor = Color.Red;
}
private void ShowCounter()
{
string strMsg = this.ncount.ToString( "D8" );
this.label1.Text = strMsg;
}
private void button1_Click(object sender, EventArgs e)
{
this.ncount++;
this.ShowCounter();
}
private void button2_Click(object sender, EventArgs e)
{
this.ncount--;
this.ShowCounter();
}
private void button3_Click(object sender, EventArgs e)
{
string strMsg = "當前計數為:" + this.ncount.ToString( "D8" );
MessageBox.Show( strMsg,"提示" );
}
private void Form1_Click(object sender, EventArgs e)
{
MessageBox.Show( "單擊了視窗!");
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult dr = MessageBox.Show( "是否關閉視窗?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Warning );
if (dr == DialogResult.Yes)
{
e.Cancel = false;
}
else
{
e.Cancel = true;
}
}
}
}
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/5F/DB/wKiom1UqZNzBEq0AAADVPCri96o813.jpg" title="ET4D3%M7`3W3{W)00}S1WNB.png " alt="wKiom1UqZNzBEq0AAADVPCri96o813.jpg" />
本文出自 “郭俊的部落格” 部落格,轉載請與作者聯絡!
C#自學之路19