Editing a DataGridView through a constructor in an inherited UserControl

I created a UserControl with Button, TextBox and DataGridView. I install modifiers of all controls publicly.

Now, if I inherit this UserControl, I can change the TextBox and Button through Designer (moving, changing properties) as I expected. But for DataGridView, all properties are disabled.

Is there a reason why I cannot change the DataGridView through the constructor in the inherited UserControl?

+3
source share
1 answer

Found a solution here: http://adamhouldsworth.blogspot.com/2010/02/winforms-visual-inheritance-limitations.html

In short:

  • System.Design
  • DataGridView :

    [Designer(typeof(ControlDesigner))]
    public class InheritableDataGridView : DataGridView
    {
        public InheritableDataGridView()
            : base()
        { }
    }
    
  • ???
  • Profit!!!
+4

Source: https://habr.com/ru/post/1774505/


All Articles