【问题标题】:c# derive a class from a componentc# 从组件派生一个类
【发布时间】:2019-03-18 08:38:34
【问题描述】:

我从组件 (DataGridView) 派生了一个类。如何将我的组件放置在 Visual Studio 组件面板中。

 class WorkerGrid:DataGridView
{
    public Worker Worker { get; }
    public DateTime DateStart { get; set; }
    public DateTime DateEnd { get; set; }

    public void Load()
    {

    }
}

【问题讨论】:

标签: c# .net components derived-class


【解决方案1】:

取决于Microsoft

创建项目

第一步是创建项目并设置表单。

  • 创建一个名为 ToolboxExample 的基于 Windows 的应用程序项目
    (文件 > 新建 > 项目 > Visual C# > 经典 桌面 > Windows 窗体应用程序)。
  • 向项目中添加一个新组件。称之为 DemoComponent。
    • (有关详细信息,请参阅 NIB:如何:添加新项目项。)
  • 构建项目。
  • 工具菜单中,单击选项项。单击常规下的 Windows 窗体设计器 项并确保 AutoToolboxPopulate 选项设置为 True

创建自定义组件的实例

  • 表单设计器中打开项目的表单。
  • 工具箱中,点击名为ToolboxExample Components的新标签。
  • 单击选项卡后,您将看到 DemoComponent
  • 将组件拖到表单上。该组件的一个实例是 创建并添加到组件托盘

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-04
    • 1970-01-01
    • 2021-04-01
    • 2016-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多