Hi

grid colors

public void bind()
        {
            try
            {
                DataTable dt = Bussiness.selectData();
                dgvMangaeCompliants.DataSource = dt;
                if (dt.Rows.Count > 0)
                {
                  
                    foreach (DataGridViewRow row in dgvMangaeCompliants.Rows)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            int j = Convert.ToInt32(dt.Rows[i]["currentstate"].ToString());
                            if (j == 4)
                            {
                                dgvMangaeCompliants.Rows[i].DefaultCellStyle.BackColor = Color.Green;
                               

                            }
                            if (j == 3)
                            {
                                dgvMangaeCompliants.Rows[i].DefaultCellStyle.BackColor = Color.Blue;
                               

                            }
                            if (j == 2)
                            {
                                dgvMangaeCompliants.Rows[i].DefaultCellStyle.BackColor = Color.BurlyWood;
                               

                            }
                            if (j == 1)
                            {
                                dgvMangaeCompliants.Rows[i].DefaultCellStyle.BackColor = Color.White;
                               

                            }
                        }
                    }
                    
                }
                //
            }
            catch
            {
                throw;
            }
        }
Previous
Next Post »