就是 dataGrid1.Select(0); dataGrid1.Select(1);是不是选中了0 1 二个行...
private void button5_Click(object sender, EventArgs e)
{
string sql = path.Text;//连接数据库
string sele = "SELECT * from GYS ";
OleDbConnection conn = new OleDbConnection(sql);
OleDbDataAdapter dataa = new OleDbDataAdapter(sele, conn);
DataSet dataset1 = new DataSet();
conn.Open();
dataa.Fill(dataset1, "GYS");
conn.Close();
DataGridCell Mycell = new DataGridCell();
string b = "";
Mycell.ColumnNumber = 5;//字段所在列(这个列数是固定的所以可以算出)
for (int a=1;a<Convert.ToInt32((dataset1.Tables["GYS"].Rows.Count.ToString()));a++)
{
Mycell.RowNumber = a;
b = this.dataGrid1[Mycell].ToString();
if (Convert.ToInt32(b) < 60)
dataGrid1.Select(a);
}
dataGrid1.SelectionBackColor = Color.Red;
}