public void setControl(String yearId, String monthId, String periodId, String rateId) { dgv1.Rows.Clear(); Font font = new Font("Microsoft Sans Serif", 12); Font font1 = new Font("Microsoft Sans Serif", 12, FontStyle.Bold); //dgv1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgv1.SelectionMode = DataGridViewSelectionMode.CellSelect; List <Reward1> lRew1 = new List <Reward1>(); //lRew1 = lc.selectByReward(yearId, monthId, periodId, rateId); lRew1 = lc.selectByLenNumber(yearId, monthId, periodId, rateId); dgv1.ColumnCount = col1Cnt; dgv1.RowCount = 1; //row = 0; dgv1.Columns[colNumber].Width = 80; //dgv1.Columns[colUp].Width = 80; //dgv1.Columns[colTod].Width = 80; //dgv1.Columns[colDown].Width = 80; dgv1.Columns[colRpayRate].Width = 100; dgv1.Columns[colNumber].HeaderText = "ตัวเลข"; dgv1.Columns[colRAmt].HeaderText = "ยอดเงิน"; dgv1.Columns[colRAmtReward].HeaderText = "แทงถูก"; //dgv1.Columns[colTod].HeaderText = "โต๊ด"; //dgv1.Columns[colDown].HeaderText = "ล่าง"; dgv1.Columns[colRpayRate].HeaderText = "อัตราจ่าย"; dgv1.Columns[colRReward].HeaderText = "จ่าย"; dgv1.Columns[colRAmt].Visible = false; dgv1.Font = font; //lotNew = true; if (lRew1.Count > 0) { dgv1.RowCount = lRew1.Count; for (int i = 0; i < lRew1.Count; i++) { Reward1 rew1 = lRew1[i]; dgv1[colNumber, i].Value = lc.cf.stringNull1(rew1.number); dgv1[colRpayRate, i].Value = rew1.PayRate; dgv1[colRReward, i].Value = rew1.Reward; dgv1[colRAmtReward, i].Value = rew1.Amt; if (Double.Parse(lc.cf.NumberNull(dgv1[colRReward, i].Value.ToString())) > 0) { dgv1[colNumber, i].Style.Font = font1; dgv1[colNumber, i].Style.ForeColor = Color.Red; dgv1[colRReward, i].Style.Font = font1; dgv1[colRReward, i].Style.ForeColor = Color.Red; dgv1[colRAmtReward, i].Style.Font = font1; dgv1[colRAmtReward, i].Style.ForeColor = Color.Red; } if (rateId.Equals("up")) { dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#174e75"); } else if (rateId.Equals("down")) { dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#174e75"); } else if (rateId.Equals("2down")) { dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#789640"); } else if (rateId.Equals("2up")) { dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#789640"); } else if (rateId.Equals("2tod")) { dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#789640"); } else if (rateId.Equals("3down")) { dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#788540"); } else if (rateId.Equals("3tod")) { dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#788540"); } else if (rateId.Equals("3up")) { dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#788540"); } } } dgv1.ReadOnly = true; }