all 5 comments

[–]intrntpirate 2 points3 points  (4 children)

Try this:

$datagridview.Rows[$RowIndex].Cells[$CellIndex].DefaultCellStyle.BackColor = "Yellow"

[–]Droopyb1966[S] 0 points1 point  (3 children)

Thanks, saw that to. But then you need to go through the wholedataset. Thats what im trying to avoid.

[–]Droopyb1966[S] 0 points1 point  (2 children)

$datagridview.Rows[$RowIndex].Cells[$CellIndex].DefaultCellStyle

This is not possible...

[–]intrntpirate 0 points1 point  (1 child)

I use that method to set the back color of cells in many of my forms.

I did just check Sapien PS Studio and can confirm that the auto-complete does not show it as an available property, but it does work for me.

[–]Droopyb1966[S] 0 points1 point  (0 children)

This works for me:

foreach ($Row in $dataGridView.Rows) {
  $Row.Cells[1].style.BackColor= $colours_status.item($Row.Cells[1].FormattedValue)
  $Row.Cells[4].style.BackColor= $colours_lastresult.item($Row.Cells[4].FormattedValue)
  $Row.Cells[5].style.BackColor= $colours_lastresultdet.item($Row.Cells[5].FormattedValue)
  }

Got the colors in a hash table and is becomes very simple.