Hello again :)
I download data from database to datagrid. Everything working.
I need change a cells background color in datagrid where values is other than null.
So If i check cells like that:

dataGridView1.DataSource = datatable from database;
for (int row = 0; row < dataGridView1.RowCount-1; row++)
{
for (int column = 1; column < dataGridView1.Columns.Count; column++)
{
if (dataGridView1[column, row].Value.ToString() != "")
{
dataGridView1[column,row].Style.BackColor = Color.Yellow;
}
}
}

I check in debugger that he find cells but dont color them. Maybe its a component fault? My cells is still white. If I made event - cellsclick an they I write:

dataGridView1.currentcells.Style.BackColor = Color.Yellow;

That code will working.
What is going on?

need change a cells background color in datagrid where values is other than null.

I Guess you better try to test the Value on line 6 for null, don't test Value.ToString

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.