Edit DataGridView via Designer in inherited UserControl
I created a UserControl with a Button, a TextBox and a DataGridView. I set the modifiers of all controls to public.
Now If I inherit from that UserControl, I can modify the TextBox and the Button via Designer (move around, change properties) just as I expected. But for the DataGridView all properties are disabled.
Is there any reason, why I can't modify a DataGridView via the Designer in an inh开发者_开发百科erited UserControl?
Found a solution here: http://adamhouldsworth.blogspot.com/2010/02/winforms-visual-inheritance-limitations.html
In short:
- Add a reference to System.Design
Inherit from DataGridView with this code:
[Designer(typeof(ControlDesigner))] public class InheritableDataGridView : DataGridView { public InheritableDataGridView() : base() { } }
- ???
- Profit!!!
精彩评论