码迷,mamicode.com
首页 > Windows程序 > 详细

C#自学之路19

时间:2015-04-13 07:10:14      阅读:192      评论:0      收藏:0      [点我收藏+]

标签: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;

            }

        }

    }

}


技术分享

本文出自 “郭俊的博客” 博客,转载请与作者联系!

C#自学之路19

标签:private   图片   public   风格   

原文地址:http://10093949.blog.51cto.com/10083949/1631600

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!