type TCalendar = class(Calendar.TCalendar) protected procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override; public
end;
TForm1 = class(TForm) cal1: TCalendar; private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
uses DateUtils;
{$R *.dfm}
{ TCalendar }
procedure TCalendar.DrawCell(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState); var TheText: string; vDay: string; begin TheText := CellText[ACol, ARow]; vDay := IntToStr(DateUtils.DayOf(Now)); if vDay = TheText then begin //当天自定义样式 Canvas.Brush.Color := clRed; end else begin if (gdSelected in AState) or (gdFocused in AState) then Canvas.Brush.Color := clBlue; end; inherited;
end;
end.
#8
用了这个方法 提示这个错误
[Error] datetool.pas(36): Method 'DrawCell' not found in base class
应该是没有DrawCell 这个类吧
type TCalendar = class(Calendar.TCalendar) protected procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override; public
end;
TForm1 = class(TForm) cal1: TCalendar; private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
uses DateUtils;
{$R *.dfm}
{ TCalendar }
procedure TCalendar.DrawCell(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState); var TheText: string; vDay: string; begin TheText := CellText[ACol, ARow]; vDay := IntToStr(DateUtils.DayOf(Now)); if vDay = TheText then begin //当天自定义样式 Canvas.Brush.Color := clRed; end else begin if (gdSelected in AState) or (gdFocused in AState) then Canvas.Brush.Color := clBlue; end; inherited;
type TCalendar = class(Calendar.TCalendar) protected procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override; public
end;
TForm1 = class(TForm) cal1: TCalendar; private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
uses DateUtils;
{$R *.dfm}
{ TCalendar }
procedure TCalendar.DrawCell(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState); var TheText: string; vDay: string; begin TheText := CellText[ACol, ARow]; vDay := IntToStr(DateUtils.DayOf(Now)); if vDay = TheText then begin //当天自定义样式 Canvas.Brush.Color := clRed; end else begin if (gdSelected in AState) or (gdFocused in AState) then Canvas.Brush.Color := clBlue; end; inherited;
end;
end.
用了这个方法 提示这个错误
[Error] datetool.pas(36): Method 'DrawCell' not found in base class
应该是没有DrawCell 这个类吧