Skip to main content

DataGridView : How can you change the background colour of a line?

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

In a DataGridView object from the .Net Framework V2 and above. How can you change the background colour of "row" programatically?

Resolution:

You can use the "DefaultCellStyle" on the row to acheive this:-

set datagridview1::"Rows"::"Item"(ls-count)::"DefaultCellStyle"::"BackColor" to cColor::"LimeGreen"

This sets the background colour to Lime Green.

Old KB# 3922