Hi Added this peace of code, Im trying to to just click any cell ,row or column during runtime and highlight with a color.
Instead it highlights everything instead. I think is because of the
loop. let me try something else. If you have any ideas please dont
hesitate
try
{
colorDialog1.ShowDialog();
for (int i = 0; i < dataGridView2.Rows.Count; i++)
{
/*if (Convert.ToUInt32(dataGridView2.Rows[i].Cells[9].Value) == 0)
{
this.dataGridView2.Rows[i].DefaultCellStyle.BackColor = Color.Red;
}*/
if (Convert.ToUInt32(dataGridView2.Rows[i].Cells[i].Value) == 0)
{
this.dataGridView2.Rows[i].DefaultCellStyle.BackColor = colorDialog1.Color;
}
}
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
Loading

naura paxRank #2,843 · 502 reputationPosted Feb 22, 2010, 9:49 PM EST
for (int i = 0; i < dataGridView2.Rows.Count; i++)
{
for(int j=0;j
{
if (Convert.ToUInt32(dataGridView2.Rows[i].Cells[j].Value) == 0)
{
this.dataGridView2.Rows[i].DefaultCellStyle.BackColor = colorDialog1.Color;
}
}
}
}
David SmithRank #999 · 2K reputationPosted Feb 22, 2010, 10:02 PM EST
dataGridView2.Rows[dataGridView2.CurrentCell.Value].DefaultCellStyle.BackColor = colorDialog1.Color;
but you cant convert object to int
David SmithRank #999 · 2K reputationPosted Feb 22, 2010, 10:30 PM EST
dataGridView2.CurrentCell.Style.BackColor = colorDialog1.Color;
naura paxRank #2,843 · 502 reputationPosted Feb 22, 2010, 11:22 PM EST
by the way this is the one that will work for sure
dataGridView2.Rows[dataGridView2.CurrentCell.RowIndex].DefaultCellStyle.BackColor= colorDialog1.Color;
paul daniel189 reputationPosted Feb 22, 2010, 11:30 PM EST
http://csharpdotnetfreak.blogspot.com/2009/04/highlight-gridview-mouseover-javascript.html
http://www.highoncoding.com/Articles/172_Changing_GridView_Row_Color_OnMouseOver.aspx