Been playing with the UI of my program and have a little function that compares to cells on the same row and assigns a colour to that cell.
What I actually want now is to simply add an image UP or DOWN arrow to that cell. Unfortunately there seems to be no one liner which I find hard to believe.
Here’s my current code:
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;
}
}
}
Im hoping someone knows that there is a one liner. Oh and the column I want to add an image too is a DataGridViewImageCell.
Many thanks!
so far I simply create a new Image and then
paretoRow.Cells["p1"].Value = theImage;
Problem I get is ERROR:formated cell has wrong type!
You should use DataGridTemplateColumn contains image control. General column dosen’t support to show image.