Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法以继承的形式直观地更改DataGridView_C#_Winforms_Visual Studio 2010_Inheritance - Fatal编程技术网

C# 无法以继承的形式直观地更改DataGridView

C# 无法以继承的形式直观地更改DataGridView,c#,winforms,visual-studio-2010,inheritance,C#,Winforms,Visual Studio 2010,Inheritance,我有一个WinForms表单,上面有一个DataGridView。DataGridView设置为protected 当我继承该表单时,无法在VisualStudio设计器中更改DataGridView。如果我用一个按钮来完成整个过程,它将按预期工作 有办法解决这个问题吗 一些(剪裁的)代码(来自DatagridForm.Designer.cs): 和从Inherited.cs: partial class Inherited : DatagridForm { } 这有一个解决方案:只需创建一

我有一个WinForms表单,上面有一个
DataGridView
DataGridView
设置为
protected

当我继承该表单时,无法在VisualStudio设计器中更改
DataGridView
。如果我用一个
按钮来完成整个过程,它将按预期工作

有办法解决这个问题吗

一些(剪裁的)代码(来自DatagridForm.Designer.cs):

和从Inherited.cs:

partial class Inherited : DatagridForm {

}
这有一个解决方案:只需创建一个继承的用户控件,该控件指向正确的设计器内容:

[Designer(typeof(System.Windows.Forms.Design.ControlDesigner))]
public class ucInheritedDataGridView : DataGridView { }
工作起来很有魅力。唯一的缺点是您不能使用.NET客户端配置文件,因为它不支持System.Forms.Design(您必须添加
System.Design
作为参考)。这应该不是什么大问题,因为客户端配置文件是


如果您确实需要客户端配置文件,另一个解决方法是将
DataGridView
包装在
面板中,您可以移动该面板并调整其大小。

您可以给我们一些代码,例如吗?添加了一些代码。我可以在继承的
设计器中轻松移动按钮。
DataGridView
被锁定,即使
locked
设置为
False
。这似乎是旧的:
[Designer(typeof(System.Windows.Forms.Design.ControlDesigner))]
public class ucInheritedDataGridView : DataGridView { }