最终想实现的效果如下:----------------------
| 年级 | 班级 | 人数 |
----------------------
| | 1 | 30 |
| 1 |--------------
| | 2 | 35 |
----------------------
| | 1 | 30 |
| |--------------
| | 2 | 35 |
| 2 |--------------
| | 3 | 30 |
| |--------------
| | 4 | 35 |
----------------------
| 年级 | 班级 | 人数 |
----------------------
| | 1 | 30 |
| 1 |--------------
| | 2 | 35 |
----------------------
| | 1 | 30 |
| |--------------
| | 2 | 35 |
| 2 |--------------
| | 3 | 30 |
| |--------------
| | 4 | 35 |
----------------------
1 1 11 0
1 2 22 1
1 3 33 1
1 4 44 1
2 1 11 0
2 2 22 1
3 1 11 0
3 2 22 1
3 3 33 1这样
procedure TForm1.DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState);
begin
if (DBGridEh1.DataSource.DataSet.FieldByName('年纪重复').AsInteger=1) and (Column.FieldName='年纪') then
begin
AFont.Color:=DBGridEh1.Color;
end;
end;(当然如果在数据录入的时候如何录入 '年纪重复' 的值 可能是个很大的麻烦 虽说楼主所要求的正解 也不妨参考一下)