2

这里我创建了一个BaseForm,然后将其所有BaseForm.Designer.cs private成员设置为protected. 然后有一个视觉继承/派生的Form

现在我可以Form在设计时重新调整或修改派生的所有控件,除了DataGridView. 我发现DataGridViewas 锁定在派生 中Form,即使它没有锁定在BaseForm.

可能是什么原因?我应该再次寻找/检查什么?

我有一个这样的基本形式:替代文字

我得到了这样的形式:替代文字

4

3 回答 3

1

这是一个已知的问题..

https://connect.microsoft.com/VisualStudio/feedback/details/284335/designer-prevents-access-to-protected-datagridview-control-in-inherited-form

您可以创建一个用户控件类并从 DataGridView 类派生

[Designer(typeof(System.Windows.Forms.Design.ControlDesigner))]
public class MyDataGridViewUserControl : DataGridView { }
于 2013-11-27T09:38:41.863 回答
0

I guess that VS designer locks controls that came from base classes. Because you have same initialization code you would change properties of grid inside of base class, that affects all other derived forms.

If you want to change properties of your grid, I would recommend to have separate grid for child form, since it should behave differently.

于 2010-10-22T15:37:27.443 回答
0

某些 .NET 控件似乎存在问题。这里有一篇好文:

DataGridView 锁定在继承的 UserControl 上

于 2013-11-27T09:28:46.450 回答