2
votes

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.

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: alt text

And I have derived a form like this: alt text

3
This is where things get ugly. DGV has a fancy custom designer, it doesn't work for inherited grids. Lots of the .NET 2.0 controls have this problem, I'm not aware of a workaround.Hans Passant
OK. Thanks for the info anyway.user366312

3 Answers

1
votes

It is a known problem..

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

You can create a user control class and derive from DataGridView class

[Designer(typeof(System.Windows.Forms.Design.ControlDesigner))]
public class MyDataGridViewUserControl : DataGridView { }
0
votes

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.

0
votes

It seems an issue with some .NET controls. There's a good writing here:

DataGridView locked on a inherited UserControl