I'm trying to change the color only for the first color of a DataGrid in a smartDevice project in c#. I tried to use the "Paint" event but couldn't figure out if it could solve my issue. I'm using Microsoft Visual Studio 2008.
This is a testing code
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);
}
Just do this will work... 0 means the first row.