本文介绍了如何更改datagridiew最后一行C#的字体颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!我想知道如何在最后一行更改datagridview的forecolor。



我尝试过:



textBox2.Text = Add_Food_Inventory.setaluefortext204;

dateTimePicker1.Text = System.DateTime.Now.ToString();

dateTimePicker2.Text = Add_Food_Inventory .setaluefortext202;

dateTimePicker3.Text = Add_Food_Inventory.setaluefortext203;

button1.PerformClick();

int sum = 0;

for(int i = 0; i< dataGridView1.Rows.Count; ++ i)

{

sum + = Convert.ToInt32(dataGridView1。行[i] .Cells [1] .Value);

}

textBox1.Text = sum.ToString();

int sum1 = 0;

for(int i = 0; i< dataGridView1.Rows.Count; ++ i)

{

sum1 + = Convert.ToInt32(dataGridView1.Rows [ i] .Cells [2] .Value);

}

textBox3.Text = sum1.ToString();

// PopulateRows( );

int rowIdx = dataGridView1.Rows.Count - 1;

dataGridView1.Rows [rowIdx] .Cells [0] .Value =Total;

dataGridView1.Rows [rowIdx] .Cells [1] .Value = sum;

dataGridView1.Rows [rowIdx] .Cells [2] .Value = sum1;

i想要改变sun和sum1 forecolor in red

解决方案



Hello guys! i want to know how to change forecolor of datagridview last row.

What I have tried:

textBox2.Text = Add_Food_Inventory.setaluefortext204;
dateTimePicker1.Text = System.DateTime.Now.ToString();
dateTimePicker2.Text = Add_Food_Inventory.setaluefortext202;
dateTimePicker3.Text = Add_Food_Inventory.setaluefortext203;
button1.PerformClick();
int sum = 0;
for (int i = 0; i < dataGridView1.Rows.Count; ++i)
{
sum += Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value);
}
textBox1.Text = sum.ToString();
int sum1 = 0;
for (int i = 0; i < dataGridView1.Rows.Count; ++i)
{
sum1 += Convert.ToInt32(dataGridView1.Rows[i].Cells[2].Value);
}
textBox3.Text = sum1.ToString();
//PopulateRows();
int rowIdx = dataGridView1.Rows.Count - 1;
dataGridView1.Rows[rowIdx].Cells[0].Value = "Total";
dataGridView1.Rows[rowIdx].Cells[1].Value = sum;
dataGridView1.Rows[rowIdx].Cells[2].Value = sum1;
i want to change sun and sum1 forecolor in red

解决方案



这篇关于如何更改datagridiew最后一行C#的字体颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 19:44