首页 > 其他 > 详细

C#学习笔记(5)

时间:2014-03-01 04:51:18      阅读:400      评论:0      收藏:0      [点我收藏+]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace demo5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            textBox1.Text = trackBar1.Value.ToString();		//显示所调节的button1的宽度
            button1.Width = trackBar1.Value;       			//设置button1的宽度
        }


        private void trackBar2_Scroll(object sender, EventArgs e)
        {
            textBox2.Text = trackBar2.Value.ToString();
            button1.Height = trackBar2.Value;
        }


        private void button1_Click(object sender, EventArgs e)
        {
            ButtonParameter BP = new ButtonParameter();   //实例化一个ButtonParameter对象BP
            BP.Text = "按钮控件";   					//BP的Text属性设置为“按钮控件”
            button1.Text = BP.Text; 						//设置button1的Text属性
            button1.Height = BP.Height;					//设置button1的Height属性
            button1.Width = BP.Width;  					//设置button1的Width属性


            label1.Text = "默认高度为:";
            label2.Text = "默认宽度为:";
            textBox1.Text = BP.Height.ToString();			//显示默认高度
            textBox2.Text = BP.Width.ToString();			//显示默认宽度
        }
        class ButtonParameter       						//定义类ButtonParameter
        {
            private string _text;   							//按钮的Text属性值
            private int _height;    							//按钮的Height属性值
            private int _width;     							//按钮的Width属性值
            public ButtonParameter()						//构造函数
            {
                _height = 23;
                _width = 75;
            }
            public string Text								//Text属性,可读可写
            {
                get									//读访问器
                { return _text; }
                set									//写访问器
                { _text = value; }
            }
            public int Height   							//只读属性,Height属性
            {
                get
                { return _height; }
            }
            public int Width    							//只读属性,Width属性
            {
                get
                { return _width; }
            }
        }
    }
}
bubuko.com,布布扣

C#学习笔记(5),布布扣,bubuko.com

C#学习笔记(5)

原文:http://blog.csdn.net/jkxqj/article/details/20147011

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!