0

我正在尝试仅更改 c# 中 smartDevice 项目中 DataGrid 的第一种颜色的颜色。我尝试使用“Paint”事件,但不知道它是否可以解决我的问题。我正在使用 Microsoft Visual Studio 2008。

这是一个测试代码

private void buttonRed_Click(object sender, EventArgs e)
    {
        DataRow row = this.dataSet1.Tables[0].NewRow();
        row[0] = "002";
        row[1] = "E";
        this.dataSet1.Tables[0].Rows.InsertAt(row, 0);
    }
    private void load()
    {

        this.dataSet1.Tables[0].Rows.Add(new object[] { "001", "A" });
        this.dataSet1.Tables[0].Rows.Add(new object[] { "002", "B" });
        this.dataSet1.Tables[0].Rows.Add(new object[] { "001", "C" });
        this.dataSet1.Tables[0].Rows.Add(new object[] { "003", "D" });
    }
    private void buttonGreen_Click(object sender, EventArgs e)
    {
        DataRow row = this.dataSet1.Tables[0].NewRow();
        row[0] = "004";
        row[1] = "F";
        this.dataSet1.Tables[0].Rows.InsertAt(row, 0);
    }
4

1 回答 1

1
dataGridView1.Rows[0].DefaultCellStyle.BackColor = Color.Azure;

只要这样做就可以了... 0 表示第一行。

于 2014-05-20T08:11:47.950 回答