用dbgrid吧<br>dbgrid的内容连接学生数据库,给你个dbgrid按照不同内容改变颜色的例子<br>color1...colorn代表不同的颜色<br>procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;<br> DataCol: Integer; Column: TColumn; State: TGridDrawState);<br>begin<br>case dbgrid1.DataSource.DataSet.FieldByName('parttag').AsInteger of<br> 1:dbgrid1.Canvas.Brush.Color := color1; //行底色<br> 0:dbgrid1.Canvas.Brush.Color := color2; //行底色<br> else<br> dbgrid1.Canvas.Brush.Color := clWindow; //行底色<br> end;<br><br><br> If gdSelected in State then<br> begin<br> DBGrid1.Canvas.Brush.Color := clGradientActiveCaption;<br> DBGrid1.Canvas.Font.Color := clred;<br> end;<br> DBGrid1.DefaultDrawColumnCell(Rect,DataCol,column,state);<br>end;