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;
The 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: 1 + 4=iDays +;
EasyGrid1. SetMerges (the Rect (1, 1, 1, 2));
EasyGrid1. SetMerges (the Rect (2, 1, 2, 2));
EasyGrid1. SetMerges (the Rect (3, 1, 3, 2));//the first 3 columns
ForeText EasyGrid1. Cells [1, 1]='shift';
AlignMode EasyGrid1. Cells [1, 1]=taCenter;
ForeText EasyGrid1. Cells [2, 1]='monitor';
AlignMode EasyGrid1. Cells [2, 1]=taCenter;
ForeText EasyGrid1. Cells (3, 1]='number;
AlignMode EasyGrid1. Cells (3, 1]=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
The begin
J:=DaysInAMonth (iYear_Q, iMonth_Q + I);//total number of days this month
If I=0 then
The begin
If (iYear_Q=iYear_Z) and (iMonth_Q=iMonth_Z) then
K:=iDay_Z iDay_Q + 1
The else
K:=j - iDay_Q + 1;//need to draw the number of days
IFirst_M:=k;
End
The else
K:=iDay_Z;//need to draw the number of days in
EasyGrid1. SetMerges (the 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) + month ';
EasyGrid1. Cells [4 + iFirst_M * I, 1] AlignMode:=taCenter;
EasyGrid1. InvalidateRow (1);
If k=iFirst_M then//filling date
The begin
Do the for iCol:=0 to k - 1
The begin
EasyGrid1. Cells [iCol + 4, 2]. The ForeText:=inttostr (iDay_Q + iCol);
EasyGrid1. Cells [iCol + 4, 2] AlignMode:=taCenter;
The end;
End
The else
The begin
Do the for iCol:=0 to k - 1
The begin
EasyGrid1. SetMerges (the Rect (iFirst_M iCol + 4 + 1, k + 3 + iFirst_M * I, 1));
EasyGrid1. Cells [iFirst_M, iCol + 4 + 2] ForeText:=inttostr (iCol + 1);
EasyGrid1. Cells [iFirst_M, iCol + 4 + 2] AlignMode:=taCenter;
The end;
The end;
The end;
EasyGrid1. InvalidateGrid;
EasyGrid1. AutoUpdate:=true;
The end;
CodePudding user response:
EasyGrid. The first selection, and then merge once, again to regenerate