Is there a OnDrawColumnCell equivalent event when using TDBAdvGrid?
Have you considered OnDrawCell ?
I have the below on the OnDrawCell event, but only the first record in AdsQryRooms is processed. i.e the Floor_Name & RoomTypeName data do not change.
The cols 2 and 3 are dummy columns, the TDBdvGrid's datasource is a datasource connected to the AdsQryRooms query.
When I use OnDrawColumnCell (TDBGrid) I have no problems.
{OnDrawCell}
procedure TRoomOps.dbGrdRoomsDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
Var
cTop, cLeft, cBottom, cRight: Integer;
begin
if ARow <> 0 then
begin
if ACol = 3 then
begin
cTop := Rect.Top + 2;
cLeft := Rect.Left + 3;
if DM.AdsTblHSFloors.FindKey([iPropertyNo, AdsQryRooms.FieldByName('FloorNo').AsInteger]) then
dbGrdRooms.Canvas.TextOut(cLeft, cTop, DM.AdsTblHSFloors.FieldByName('Floor_Name').AsString);
end;
if ACol = 4 then
begin
cTop := Rect.Top + 2;
cLeft := Rect.Left + 3;
if DM.AdsTblHSRoomType.FindKey([iPropertyNo, AdsQryRooms.FieldByName('RoomTypeNo').AsString]) then
dbGrdRooms.Canvas.TextOut(cLeft, cTop, DM.AdsTblHSRoomType.FieldByName('RoomTypeName').AsString);
end;
end;
end;
{OnDrawColumnCell - Example}
procedure TRoomTypefrm.DbGrdRoomTypeDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
Var
cTop, cLeft, cBottom, cRight: Integer;
begin
if Column.Index = 2 then
begin
cTop := Rect.Top + 2;
cLeft := Rect.Left + 3;
DM.AdsTblCurrency.FindKey([AdsQryRooms.FieldByName('Currency').AsString]);
DbGrdRoomType.Canvas.TextOut(cLeft, cTop, DM.AdsTblCurrency.FieldByName('Currency').AsString);
end;
end;
It is not recommended to use the values directly from the dataset but please get the data itself directly via grid.Cells[col,row]: string;