但這有個缺點 -- 當欄位數超過 DBGrid 寬度時,就無法以方向鍵的向左/右鍵去其他欄位,並且無法修改個別欄位。
所以要另外拐個彎處理......
- type
- THackDBGrid = class(TDBGrid)
- end;
- TForm1 = class(TForm)
- ....
- end;
- procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
- begin
- if THackDBGrid(DBGrid1).Row=(1+THackDBGrid(DBGrid1).DataLink.ActiveRecord) then
- begin
- with DBGrid1.Canvas do
- begin
- Brush.Color := clSilver;
- Font.Color := clNavy;
- end;
- end;
- DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State) ;
- end;
沒有留言:
張貼留言