【问题标题】:Modify a control in C#在 C# 中修改控件
【发布时间】:2015-10-22 16:44:19
【问题描述】:

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

【问题讨论】:

  • 欢迎来到 Stack Overflow,如果没有正确的描述和代码,我们将无法为您提供帮助。请阅读有关如何提问的常见问题解答。
  • 我没有任何代码 Greg!我在谈论 MonthCalendar 类,它具有属性,我想添加一个但我不能:p

标签: c# controls monthcalendar


【解决方案1】:

创建一个新类,比如 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 工具箱中可用,将其拖放到您的表单中。

【讨论】:

    猜你喜欢
    • 2014-09-23
    • 2012-07-01
    • 1970-01-01
    • 2019-08-18
    • 2010-10-15
    • 2011-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多