本人水平有限,如有写得不对的地方,望指正。为了简单化,做了一个简陋版的温度计控件,有点丑哈。本文的内容仅供参考
测试环境:
visual studio 2017
.net framework 4.0
效果图如下:
步骤如下:
1 新建名为WinformDemo1的winform项目,.net framework选择4.0
2 新建名为ThermometerControl的类,并编辑如下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WinformDemo1
{
public class ThermometerControl:System.Windows.Forms.UserControl
{
private int _temperature = 0;
[Browsable(true), Category("自定义属性"), Description("设置温度值")]
public int Temperature
{
set { _temperature = value; Val