//这里是赋值
private void button1_Click(object sender, EventArgs e)
{
this.dataGridView1.DataSource = DBcon.getTable("select id as ID,xiangmu as 调查项目名称,henmanyi as 很满意,manyi as 满意,yiban as 一般,bumanyi as 不满意,henbumanyi as 很不满意,defeng as 得分 from shuju where fuwuduixiang='服务' and danhao='" + this.label2.Text + "' and gongsimingcheng='" + main.gsmc + "'");
getcolor(this.dataGridView1); } //赋值时datagredview 的选中状态颜色
private void getcolor(DataGridView gridview)
{
for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
{
for (int j = 2; j < 7; j++)
{
if (Convert.ToBoolean(dataGridView1.Rows[i].Cells[j].Value) == true)
{
this.dataGridView1.Rows[i].Cells[j].Style.BackColor = System.Drawing.Color.Red;
}
}
}
} 很满意 满意 一般 不满意 很不满意 这5个在数据库汇总是 bit 为什么我 现在调用 getcolor(this.dataGridView1); 时候 不会变色啊???
我调试 只要数据库为 true 也执行了this.dataGridView1.Rows[i].Cells[j].Style.BackColor = ystem.Drawing.Color.Red;但是 最后打开就是 没颜色啊 为什么啊??? 高手帮忙啊
private void button1_Click(object sender, EventArgs e)
{
this.dataGridView1.DataSource = DBcon.getTable("select id as ID,xiangmu as 调查项目名称,henmanyi as 很满意,manyi as 满意,yiban as 一般,bumanyi as 不满意,henbumanyi as 很不满意,defeng as 得分 from shuju where fuwuduixiang='服务' and danhao='" + this.label2.Text + "' and gongsimingcheng='" + main.gsmc + "'");
getcolor(this.dataGridView1); } //赋值时datagredview 的选中状态颜色
private void getcolor(DataGridView gridview)
{
for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
{
for (int j = 2; j < 7; j++)
{
if (Convert.ToBoolean(dataGridView1.Rows[i].Cells[j].Value) == true)
{
this.dataGridView1.Rows[i].Cells[j].Style.BackColor = System.Drawing.Color.Red;
}
}
}
} 很满意 满意 一般 不满意 很不满意 这5个在数据库汇总是 bit 为什么我 现在调用 getcolor(this.dataGridView1); 时候 不会变色啊???
我调试 只要数据库为 true 也执行了this.dataGridView1.Rows[i].Cells[j].Style.BackColor = ystem.Drawing.Color.Red;但是 最后打开就是 没颜色啊 为什么啊??? 高手帮忙啊
DataGridViewCellStyle { SelectionBackColor=Color [White], SelectionForeColor=Color [Black] }//选中一行selectionMode面板上有这个属性。设置为fullrowSelect表示选中一行。
{
this.dataGridView1.Rows[i].Cells[j].Style.BackColor = System.Drawing.Color.Red;
}
试试。。这样子