更改Calendar1中某一天的底色,为什么点下一个单元格,着色就消失了?大家帮看看...仅有的分,不够下次补上...谢了.
procedure TDayForm.N1Click(Sender: TObject);
var
TheText: string;
x1,y1,x2,y2:integer;
w,h:integer;
begin
TheText := Calendar1.CellText[3,3];
Calendar1.Brush.Color:=clred;
x1:=Tstringgrid(calendar1).CellRect(3,3).left;
y1:=Tstringgrid(calendar1).CellRect(3,3).top;
x2:=Tstringgrid(calendar1).CellRect(3,3).right;
y2:=Tstringgrid(calendar1).CellRect(3,3).bottom;
w:=tstringgrid(calendar1).Canvas.textwidth(thetext);
h:=tstringgrid(calendar1).Canvas.textheight(thetext);
tstringgrid(calendar1).Canvas.Brush.Color:=clGreen;
tstringgrid(calendar1).Canvas.TextRect(Tstringgrid(calendar1).CellRect(3,3),
x1+(x2-x1-w) div 2,y1+(y2-y1-h) div 2,thetext);
end;
procedure TDayForm.N1Click(Sender: TObject);
var
TheText: string;
x1,y1,x2,y2:integer;
w,h:integer;
begin
TheText := Calendar1.CellText[3,3];
Calendar1.Brush.Color:=clred;
x1:=Tstringgrid(calendar1).CellRect(3,3).left;
y1:=Tstringgrid(calendar1).CellRect(3,3).top;
x2:=Tstringgrid(calendar1).CellRect(3,3).right;
y2:=Tstringgrid(calendar1).CellRect(3,3).bottom;
w:=tstringgrid(calendar1).Canvas.textwidth(thetext);
h:=tstringgrid(calendar1).Canvas.textheight(thetext);
tstringgrid(calendar1).Canvas.Brush.Color:=clGreen;
tstringgrid(calendar1).Canvas.TextRect(Tstringgrid(calendar1).CellRect(3,3),
x1+(x2-x1-w) div 2,y1+(y2-y1-h) div 2,thetext);
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货