I am in the process of creating many custom controls, each with a grid control in it (the Complete Grid Control)
I wanted to try and make all of these grid controls inherit from some base control so that code does not have to be duplicated and every control follows the same standard
So I have properties
DataSource
And
CheckedCollection as each grid will have checkboxes and to return the records the user selected
I have method
BindData which users of the control can call to performs the internal control databind
The Abstract Base Class will have to be of T so that DataSource and Check Collection can return List<T>
The part where I am stuck is I have a SetVisible method which takes in an Enum Flag and a bool. So currently for a grid I have
public enum GridColumnsFlags
{
CheckBox = 1,
StartDate = 2,
Product = 4,
SalesPerson = 8,
Status = 16,
All = 31
}
private enum GridColumns
{
CheckBox = 1,
StartDate,
Product,
SalesPerson,
Status
}
Then a call would be like
SetVisible(GridColumnsFlag.CheckBox | GridColumnsFlag.Product, true);
That works today because each grid has its own Enum. Now finally the question. I know enums can not be inherited nor put in an interface because they are a type not an object but is there a way to have the Base class refernce the parent classes enum (even if they are name the same)
So I would be able to write the code similar to
private void SetVisableProperty(GridColumnsFlags flag, bool visable)
{
if ((flag & GridColumnsFlags.CheckBox) == GridColumnsFlags.CheckBox)
{
ProductGrid.Columns[(int) GridColumns.CheckBox].Visible = visable;
}
if ((flag & GridColumnsFlags.PriceRequestId) == GridColumnsFlags.PriceRequestId)
{
ProductGrid.Columns[(int)GridColumns.PriceRequestId].Visible = visable;
}
…
Maybe use a loop or reflection to get the members of the enum, as the values would be different then each grid?
Hope all of this makes some sense.