C#Winforms带有DataGridView的可视继承问题 [英] C# Winforms visual inheritance problem with DataGridView

查看:124
本文介绍了C#Winforms带有DataGridView的可视继承问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自此处我创建了 BaseForm ,然后设置其所有 BaseForm.Designer.cs 私人成员以受保护的。然后有一个视觉上继承/派生的 Form

From here I have created a BaseForm, then set all its BaseForm.Designer.cs private members to protected. Then has had a visually inherited/derived Form.

现在,我可以调整大小或修改所有在设计时派生 Form 中的控件,但 DataGridView 除外。我发现 DataGridView 锁定在派生的 Form 中,即使它未锁定在<$ c $中c> BaseForm 。

Now I am able to re-size or modify all the controls in the derived Form in design-time except the DataGridView. I am finding the DataGridView as locked in the derived Form, even though it is not locked in the BaseForm.

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

What can be the reason? What should I look/check for again?

我有一个基本形式,如下所示:

I have a base form like this:

我派生了这样的表格:

And I have derived a form like this:

推荐答案

我猜想VS设计器会锁定来自基类的控件。因为您具有相同的初始化代码,所以您将在基类内部更改grid的属性,这会影响所有其他派生形式。

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.

这篇关于C#Winforms带有DataGridView的可视继承问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆