-
大小: 6KB文件類型: .7z金幣: 1下載: 0 次發布日期: 2021-05-16
- 語言: C#
- 標簽: PropertyGrid??
資源簡介
我們在編寫程序時可以直接通過屬性窗口對程序界面參數進行修改。十分方便,我們也可以通過 PropertyGrid 控件,來對我們的類或是控件進行快速修改。
代碼片段和文件信息
//C#源碼下載站:www.sourcecsharp.com
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
namespace?PropertyGridApp
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????propertyGrid1.Selectedobject?=?new?Go();
????????}
????????class?Go
????????{
????????????private?float?_TieMu?=?5.5f;
????????????private?string?_Rule?=?“數子法“;
????????????[CategoryAttribute(“規則“)?DescriptionAttribute(“貼目“)]
????????????public?float?TieMu
????????????{
????????????????get?{?return?_TieMu;?}
????????????????set?{?_TieMu?=?TieMu;?}
????????????}
????????????[CategoryAttribute(“規則“)?DescriptionAttribute(“計算法“)]
????????????public?string?Rule
????????????{
????????????????get?{?return?_Rule;?}
????????????????set?{?_Rule?=?Rule;?}
????????????}
????????????private?int?_Black?=?0;
????????????private?int?_White?=?0;
????????????[CategoryAttribute(“圍棋“)?DescriptionAttribute(“黑“)]
????????????public?int?Black
????????????{
????????????????get?{?return?_Black;?}
????????????????set?{?_Black?=?Black;?}
????????????}
????????????[CategoryAttribute(“圍棋“)?DescriptionAttribute(“白“)]
????????????public?int?White
????????????{
????????????????get?{?return?_White;?}
????????????????set?{?_White?=?White;?}
????????????}
????????????private?Color?_BoardColor?=?Color.Yellow;
????????????[CategoryAttribute(“圍棋“)?DescriptionAttribute(“棋盤顏色“)]
????????????public?Color?BoardColor
????????????{
????????????????get?{?return?_BoardColor;?}
????????????????set?{?_BoardColor?=?BoardColor;?}
????????????}
????????????private?Image?_Background;
????????????[CategoryAttribute(“圍棋“)?DescriptionAttribute(“棋盤背景“)]
????????????public?Image?Background
????????????{
????????????????get?{?return?_Background;?}
????????????????set?{?_Background?=?Background;?}
????????????}
????????}
????}
}
- 上一篇:C#和PLC利用modbus通信
- 下一篇:otsu閾值分割c#語言
評論
共有 條評論