在 C# 中修改控件

Modify a control in C#

我正在使用 C# 中的 monthCalendar 控件,但我想在元数据中添加一个 属性。有可能的?如果可能的话,我该如何添加 属性?

创建一个新的 class,例如 MyMonthCalendar 并从 MonthCalendar 继承它 - 包含任意数量的属性,例如 MyProperty,如下所示。

using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public class MyMonthCalendar : MonthCalendar
    {
        public int MyProperty { get; set; }
    }
}

MyMonthCalendar 将在 Visual Studio 工具箱中可用,将其拖放到您的表单中。