将DataGridTextBoxColumn DataProperty设置为数组c#的成员

时间:2014-08-07 14:57:11

标签: c# datagridview

我试图将DataGridTextBoxColumn的DataProperty属性设置为数组的元素。但是,该值未显示在datagridview上。我已配置其他列,其DataProperty未设置为数组的成员,并且它们正确显示值。

我用来设置显示数组元素数据的列的代码如下:

        // generate multiple load height columns
        DataGridViewTextBoxColumn[] loadCol = new DataGridViewTextBoxColumn[dataCollection.part.numLoadHeightValues];
        DataGridViewTextBoxColumn[] heightCol = new DataGridViewTextBoxColumn[dataCollection.part.numLoadHeightValues];
        for (int i = 0; i < dataCollection.part.numLoadHeightValues; i++) {
            //load columns
            loadCol[i] = new DataGridViewTextBoxColumn();
            loadCol[i].Name = "loadCol" + (i + 1);
            loadCol[i].HeaderText = "Load " + (i + 1);
            loadCol[i].DataPropertyName = "loadValues["+i+"]";
            //height columns
            heightCol[i] = new DataGridViewTextBoxColumn();
            heightCol[i].Name = "heightCol" + (i + 1);
            heightCol[i].HeaderText = "Height " + (i + 1);
            heightCol[i].DataPropertyName = "heightValues["+i+"]";
        }

        //add load and height columns
        for (int i = 0; i < dataCollection.part.numLoadHeightValues; i++) {
            serialConDataGrid.Columns.Add(loadCol[i]);
            serialConDataGrid.Columns.Add(heightCol[i]);
        }

我在哪里错了?

0 个答案:

没有答案