procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
bitmap : TBitmap;
fixrect : TRect;
bmpwidth : Integer;
imgindex : Integer;
begin
fixrect := Rect;
if Column.Field = EmployeeTableLastName then
begin
if EmployeeTablename.value = '张三' then
imgindex := 0
else if EmployeeTablename.value = '李四' then
imgindex := 1
else imgindex := 2;
bitmap := TBitmap.Create;
try
ImageList1.GetBitmap(imgindex,bitmap);
bmpwidth := (Rect.Bottom - Rect.Top);
fixrect.Right := Rect.Right + bmpwidth;
DBGrid1.Canvas.StretchDraw(fixrect,bitmap);
finally
bitmap.Free;
end;
fixrect := Rect;
fixrect.Right := fixrect.Right + bmpwidth;
end;
DBGrid1.DefaultDrawColumnCell(fixrect,DataCol,Column,State);
end;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
bitmap : TBitmap;
fixrect : TRect;
bmpwidth : Integer;
imgindex : Integer;
begin
fixrect := Rect;
if Column.Field = EmployeeTableLastName then
begin
if EmployeeTablename.value = '张三' then
imgindex := 0
else if EmployeeTablename.value = '李四' then
imgindex := 1
else imgindex := 2;
bitmap := TBitmap.Create;
try
ImageList1.GetBitmap(imgindex,bitmap);
bmpwidth := (Rect.Bottom - Rect.Top);
fixrect.Right := Rect.Right + bmpwidth;
DBGrid1.Canvas.StretchDraw(fixrect,bitmap);
finally
bitmap.Free;
end;
fixrect := Rect;
fixrect.Right := fixrect.Right + bmpwidth;
end;
DBGrid1.DefaultDrawColumnCell(fixrect,DataCol,Column,State);
end;
也可能是其他原因吧!
undeclared identifier:"employeetablelastname"