0

一直在玩我的程序的 UI,并且有一个小功能可以与同一行上的单元格进行比较并为该单元格分配颜色。我现在真正想要的是简单地将图像向上或向下箭头添加到该单元格。不幸的是,似乎没有一个班轮我很难相信。

这是我当前的代码:

DataGridViewImageCell p1 = new DataGridViewImageCell();

ParetoGrid.Columns.Add(new DataGridViewColumn() { CellTemplate = p1, FillWeight = 1, HeaderText = "p1", Name = "p1", Width = 30});




private void ShowArrow()
    {
        foreach (DataGridViewRow paretoRow in ParetoGrid.Rows)
        {
            if ((paretoRow.Cells["Pareto6"].Value != null) &&   (Convert.ToInt32(paretoRow.Cells["CurrentPareto"].Value) < (Convert.ToInt32(paretoRow.Cells["NewPareto"].Value))))
            {
                paretoRow.Cells["p1"].Value = //image?;
            }
            else if ((paretoRow.Cells["Pareto6"].Value != null) && (Convert.ToInt32(paretoRow.Cells["CurrentPareto"].Value) > (Convert.ToInt32(paretoRow.Cells["NewPareto"].Value))))
            {
                ParetoGrid.Rows[paretoRow.Index].DefaultCellStyle.BackColor = Color.LightGreen;
            }


        }
    }

我希望有人知道有一个班轮。哦,我也想添加图像的列是 DataGridViewImageCell。

非常感谢!

到目前为止,我只是创建了一个新图像,然后

paretoRow.Cells["p1"].Value = theImage;

我得到的问题是错误:格式化单元格的类型错误!

4

1 回答 1

0

您应该使用 DataGridTemplateColumn 包含图像控件。一般栏目不支持显示图片。

于 2012-04-27T09:06:52.573 回答