Inheritance / Polymorphism

May 24 2011 2:25 AM
Hi, I would like to know how to add a variable to collection or list in a inheriated class.
Any help would be much appreciated.

This is what I would to use it in

class MyGrid : DataGridView
{
    // Code to add the enum MyStyle to the Columns Collection, calling it DisplayStyle

    private void PaintCell(object sender, DataGridViewCellPaintingEventArgs e)
    {
        if (this.Columns[e.ColumnIndex].DisplayStyle == MyStyle.Currency)
        {
            // code here
        }
    }

    enum MyStyle
    {
        Currency, Accounting, Other
    }
}

Answers (7)