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
paul danielPosted Feb 23, 2010, 4:30 AM
http://csharpdotnetfreak.blogspot.com/2009/04/highlight-gridview-mouseover-javascript.html
http://www.highoncoding.com/Articles/172_Changing_GridView_Row_Color_OnMouseOver.aspx
naura paxPosted Feb 23, 2010, 4:22 AM
by the way this is the one that will work for sure
dataGridView2.Rows[dataGridView2.CurrentCell.RowIndex].DefaultCellStyle.BackColor= colorDialog1.Color;
David SmithPosted Feb 23, 2010, 3:30 AM
dataGridView2.CurrentCell.Style.BackColor = colorDialog1.Color;
David SmithPosted Feb 23, 2010, 3:02 AM
dataGridView2.Rows[dataGridView2.CurrentCell.Value].DefaultCellStyle.BackColor = colorDialog1.Color;
but you cant convert object to int
naura paxPosted Feb 23, 2010, 2:49 AM
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;
}
}
}
}