C#学习笔记(5)
2014-02-28 17:03
549 查看
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; } } } } }
相关文章推荐
- C# 学习笔记(File I/O with Streams) - 09
- 学习笔记之C#基础知识--String
- 《C# 设计模式》学习笔记2
- 黑马程序员之C#学习笔记: new关键字的三种用法
- C#学习笔记----AppDomain应用程序域
- C#开发学习笔记:GridControl添加右键快捷菜单
- C#学习笔记1
- 42、我的C#学习笔记8
- C#基础与常用数据结构学习笔记
- 8dc5 java和c#接口定义区别--学习笔记
- 【学习笔记】C#Json和Bson序列化中遇到的一些问题
- C#教学第15讲索引器1(学习笔记)
- CLR VIA C# 学习笔记
- C#学习笔记---委托(1)
- C#学习笔记25——C#控件
- C#学习笔记
- [学习与积累] CLR via C#(第三版)笔记——基本类型(字符串一)
- 学习笔记之---C#中的委托与事件
- C#学习笔记之集合(入门经典 11.)
- Chap 4 学习笔记-使用C#存储变量数据