在DGV中插入数组属性(C#)

时间:2018-12-21 21:31:46

标签: c# arrays class datagridview properties

我写了一个名为Section的类,它具有2个属性:AnswersTypeOfSection。 因此,TypeOfSection在DGV中可以完美显示,但是我想显示数组中每个单元的值,我该如何实现呢?

class Section
{
    private int[] Answers;
    private string TypeOfSection;

    public Section(string TypeOfSection)
    {
        Answers = new int[30];
        for (int i = 0; i < 30; i++)
        {
            this.Answers[i] = -1;
        }
        this.TypeOfSection = TypeOfSection;
    }

    public string typeOfSection
    {
        set { this.TypeOfSection = value; }
        get { return this.TypeOfSection; }
    }

    public int[] answers
    {
        set { this.Answers = value; }
        get { return this.Answers; }
    }
}

这是我其余的代码:

    List<Section> Psy1 = new List<Section>();
    Psy1.Add(new Section("English"));
    MarksDGV1.DataSource = Psy1;

0 个答案:

没有答案