C# .NET - DataGridView Cell backcolor become black,why & how resolve?

Asked By VJ chaudhary on 19-Jun-12 07:58 AM

DataGridView Cell backcolor become black, while binding with list .
why it happens & how resolve?

Thanks, In advance.
Jitendra Faye replied to VJ chaudhary on 19-Jun-12 08:00 AM
Ok, then change color like this-

 DataGrid1.Rows[index].Cells[index].Style.BackColor = System.Drawing.Color.Red;
dipa ahuja replied to VJ chaudhary on 19-Jun-12 08:36 AM
change the properties of the datagridveiw from the property window.

or you can try color dialog :

private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
  ColorDialog clr = new ColorDialog();
  FontDialog f = new FontDialog();
  if (f.ShowDialog() == DialogResult.OK && clr.ShowDialog() == DialogResult.OK)
    dataGridView1[e.ColumnIndex, e.RowIndex].Style.Font = f.Font;
    dataGridView1[e.ColumnIndex, e.RowIndex].Style.ForeColor = clr.Color;

VJ chaudhary replied to Jitendra Faye on 20-Jun-12 05:17 AM
It does not work.....
VJ chaudhary replied to dipa ahuja on 20-Jun-12 05:53 AM
 It does not work.....
my code is below

//styleTable is DataTable object which contain full data and next we use DataView to filtering data on //cell_Text_Change_event.......................at that moment cell background become black and nothing to visible

DataView styledv = styleTable.DefaultView;
              styledv.RowFilter = "[Style] LIKE '" + datagridview1.CurrentCell.EditedFormattedValue + "%'";
              if (styledv.Count > 0)
                datagridview2.DataSource = styledv;
                datagridview2.Name = "Style";

                //set datagridview2 location and visibility True
              else datagridview2.Visible = false;
//End Code
Help me if u can......
Thanx in advance