C# visually subclass datagridview control VS2005

2019-05-20 08:17发布

问题:

Maybe its something stupid, but I'm having a problem with a subclass of a DataGridView Control in VS2005 C#. I know I can subclass from almost anything by doing

public class MyDataGridView : DataGridView
{}

no problem, and I put in some things / elements I want applicable globally. Now, I take this gridview and put into a custom user control that will contain other controls too. So I have something like created by the visual designer. I grab some buttons, label, and my derived "MyDataGridView" on it.

public partial class MyCompoundDGVPlus : UserControl

So, now, I can visually draw, move, change all sorts of settings as needed, no problem.

Now, I want this "MyCompoundDGVPlus" class as the basis for other classes, of which I will manipulate settings specific, but want all to have the same look / feel, and otherwise similar flow, hence the derivations.

I've even set the "modifiers" setting to public, so I SHOULD be able to modify any of the properties of the controls at any derived level. So, now, I create a new subclass of "MyFirstDetailedDGVPlus" derived from "MyCompoundDGVPlus". Ok visually, all the label, button, datagridview appear. However, now I want to specifically define the columns of the datagridview here in this class visually, but its locked. However, the LABEL on the form, I CAN get all the property settings....

What am I missing.

回答1:

Maybe you should take a look at this post as it seems to do what you are looking for : DataGridView locked on a inherited UserControl