Access mdb データベースのテーブルに ADO 経由でバインドされた dbgrid で Delphi 2010 を使用しています。
このテーブルは、ラジオ グループ ボックスでのクリックに基づいてフィルタリングされます。
次のコードは、テーブルのデータに基づいて行を色分けしますが、次のエラー ダイアログ ボックスで失敗します。
"" is not a valid integer value
フィルタが null データセットを返す場合。レコードが返されなかった場合に色設定を呼び出さないように許可したと思っていましたが、機能していないようです。以下のコードを参照してください
procedure TMainForm.DBGridAbsenceDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
//Need to add code to detect if record exists
with DBGridAbsence.Canvas do
begin
RecordCountLabel.Caption.Text := 'Absence Records: ' + IntToStr(ADOTblAbsence.RecordCount);
font.color:=clBlack;
brush.color:=clMoneyGreen;
If ( ADOTblAbsence.State <> dsInsert ) and ( ADOTblAbsence.RecordCount > 0 ) then
begin
Font.Color := StringToColor(ADOTblAbsenceForeground.AsString);
Brush.Color:= StringToColor(ADOTblAbsenceBackground.asstring);
end;
DBGridAbsence.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
感謝して受け取ったすべての助け。次のような条件文も試したことに注意してください
if Trim(ADOTblAbsenceForeground.AsString) <> ''
しかし、これもうまくいかないようです。