C# Winforms 用对象继承用户控件并修改

标签 c# winforms visual-studio inheritance user-controls

我使用填充用户控件的 datagridview 创建了名为 ucn 的用户控件。

在我创建了另一个从ucn继承的用户控件之后:

public partial class ucnRequest : ucn
{

在设计模式下我看到了datagridview:

usercontrol inherited

没问题,但我无法添加列。

在主用户控件中,我将 Modifiers 属性更改为公共(public),但没有任何变化...

谢谢

最佳答案

我认为这是因为您的 UserControl 默认情况下不会充当 Windows 窗体编辑器中的“容器”控件,因此 Windows 窗体编辑器不会公开其公共(public)属性。

要使其成为 Windows 窗体编辑器中的“容器”控件,您可以向该类添加以下属性:

[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))] 
public class MyUserControl: System.Windows.Forms.UserControl
{
     ...

请参阅此处了解更多信息:http://support.microsoft.com/kb/813450

关于C# Winforms 用对象继承用户控件并修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16956734/

相关文章:

visual-studio - TFS2010 - 并行构建 - 单一解决方案,单一构建代理

c# - 有没有办法让 MySQL 与 Visual Studio 2012 Express 一起工作?

c# - 在 C# 中打印 pcl 文件不起作用,建议?

c# - python 中的对象初始值设定项语法 (c#)?

c# - 合并MDI工具栏

c# - ListView 中选定索引的问题

c# - 在 gridview winform 中设置数据源后无法添加新行

C# - 在字符串列表列表中重复而不是正确的值

c# - Base64 是否标准化?

c++ - Visual Studio 外部依赖项符号错误