2

I have a parent form (Form1) and a child form (Form2) that inherits from the former. They have one button and one datagridview control.

enter image description here

When i start to work on the child form (Form2), in design mode, my button properties are enabled but datagridview all properties are disabled, eventhough I set their modifiers to public.

enter image description here

enter image description here

enter image description here

How can I change these properties in the child form for DataGridView?

Omer
  • 8,194
  • 13
  • 74
  • 92
  • 1
    Can you post the code for the base form and how it's used? Specifically I want to see the constructors and class definitions for both. This sounds like a [Visual Inheritance](https://stackoverflow.com/questions/1046328/how-to-access-inherited-controls-in-the-winforms-designer) problem. – Zer0 Mar 15 '20 at 00:22
  • 2
    You need a custom control derived from DataGridView, decorate the class with a Designer attribute (as `[Designer(typeof(ControlDesigner))]`, for example, unless you have your own designers, but it's the same), then set its `Modifier = Public` in the base Form. If your derived Form is opened, close it. Rebuild the Solution. Reopen the derived Form. Watch out because the DGV's constructor in the base class, IIRC, may not be called at all (but it will be in the derived Form). Anyway, the DGV in the derived Form should be editable now – Jimi Mar 15 '20 at 05:06
  • Also, now that I think about it, the Smart Tags (what causes the main problem, IIRC), won't probably be there in the derived Form. It may not be a big issue but... – Jimi Mar 15 '20 at 05:19
  • @Jimi, that solved the problem. Thanks. – Omer Mar 15 '20 at 10:16
  • Duplicate: [C# Winforms visual inheritance problem with DataGridView](https://stackoverflow.com/questions/3998314/c-sharp-winforms-visual-inheritance-problem-with-datagridview) – TnTinMn Mar 18 '20 at 02:20

0 Answers0