大蝦們 在delphi7使用easygrid 中遇到一個問題,請教下easygrid使用怎么重繪?換下日期,表頭的第一行怎么不會重新合并?謝 謝謝指教!
procedure TForm_TEST.Button1Click(Sender: TObject);
var i,j ,k,iDays ,iYear_Q,iMonth_Q,iDay_Q ,iYear_Z,iMonth_Z,iDay_Z,iCol: integer;
iFirst_M:integer;
begin
i:=0;j:=0; k:=0;iDays:=0;iYear_Q:=0;iMonth_Q:=0;iDay_Q :=0;iYear_Z:=0;iMonth_Z:=0;iDay_Z:=0;iCol:=0;iFirst_M :=0;
EasyGrid1.Refresh;
EasyGrid1.InvalidateGrid;
EasyGrid1.ColCount:=0;
iDays:=DaysBetween(DateTimePicker1.Date,DateTimePicker2.Date ) ;
EasyGrid1.ColCount:=iDays+1+4;
EasyGrid1.SetMerges(Rect(1, 1, 1, 2));
EasyGrid1.SetMerges(Rect(2, 1, 2, 2));
EasyGrid1.SetMerges(Rect(3, 1, 3, 2)); //前3列
EasyGrid1.Cells[1,1].ForeText := '班組';
EasyGrid1.Cells[1,1].AlignMode := taCenter;
EasyGrid1.Cells[2,1].ForeText := '班長';
EasyGrid1.Cells[2,1].AlignMode := taCenter;
EasyGrid1.Cells[3,1].ForeText := '人數';
EasyGrid1.Cells[3,1].AlignMode := taCenter;
iYear_Q:=yearof(DateTimePicker1.Date);
iMonth_Q:=monthof(DateTimePicker1.Date);
iDay_Q:=dayof(DateTimePicker1.Date);
iYear_Z:=yearof(DateTimePicker2.Date);
iMonth_Z:=monthof(DateTimePicker2.Date);
iDay_Z:=dayof(DateTimePicker2.Date);
i:= iMonth_Z-iMonth_Q;
for i:=0 to i do
begin
j:=DaysInAMonth(iYear_Q,iMonth_Q+i); //本月總共天數
if i=0 then
begin
if (iYear_Q=iYear_Z) and (iMonth_Q=iMonth_Z)then
k:=iDay_Z-iDay_Q+1
else
k:=j-iDay_Q+1 ;//需要畫的天數
iFirst_M:=k;
end
else
k:=iDay_Z; //需要畫的天數 月份
EasyGrid1.SetMerges(Rect(4+iFirst_M*i, 1, k+3+iFirst_M*i, 1),true);
EasyGrid1.Cells[4+iFirst_M*i,1].ForeText := inttostr(iMonth_Q+i)+月份';
EasyGrid1.Cells[4+iFirst_M*i,1].AlignMode := taCenter;
EasyGrid1.InvalidateRow(1);
if k=iFirst_M then //填日期
begin
for iCol := 0 to k-1 do
begin
EasyGrid1.Cells[iCol+4,2].ForeText := inttostr(iDay_Q+iCol);
EasyGrid1.Cells[iCol+4,2].AlignMode := taCenter;
end;
end
else
begin
for iCol := 0 to k-1 do
begin
EasyGrid1.SetMerges(Rect(iCol+4+iFirst_M, 1, k+3+iFirst_M*i, 1));
EasyGrid1.Cells[iCol+4+iFirst_M,2].ForeText := inttostr(iCol+1);
EasyGrid1.Cells[iCol+4+iFirst_M,2].AlignMode := taCenter;
end;
end;
end;
EasyGrid1.InvalidateGrid;
EasyGrid1.AutoUpdate:=true;
end;


uj5u.com熱心網友回復:
先EasyGrid.selection ,然后合并一下,再重新生成轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/46049.html
標籤:語言基礎/算法/系統設計
