This question was raised to me recently and it peeked my interest to solve and find out how to do this. After digging around i found 2 working codes for my case.
To explain further my tables are generated dynamically so the column widths and gaps differ by each refresh of the table
There are the 2 options that i found
Hope this code helps out somebody out there. If you have any questions, just drop me a line.
So far I have recreated this code far more in the 16 years that I have been using Delphi. Just wanted to log it here so that when I need it again, it will be here.
Hope it can also help other people
Enjoy
Coffee Cup
procedure TfrmPassword.BitBtn1Click(Sender: TObject); var vWeekDay : String; begin //DateUtils //get the first and last day if (ALMONTH.VALUE <= 11) then begin ALFROM.VALUE := StrToDate( ALMONTH.Text + ‘/01/’ + ALYEAR.Text ); ALTO.VALUE := StrToDate( IntToStr(ALMONTH.VALUE + 1) + ‘/01/’ + ALYEAR.Text ) – 1; end else begin ALFROM.VALUE := StrToDate( ’12/01/’ + ALYEAR.Text ); ALTO.VALUE := StrToDate( ’01/01/’ + inttostr(ALYEAR.Value + 1) ) – 1; end; //loop the number of days ALDAYS.VALUE := DaysBetween(ALTO.VALUE, ALFROM.VALUE) + 1; ALDATE.VALUE := ALFROM.VALUE; ALSUN.VALUE := 0; ALTOTAL.Value := 0; while (ALDATE.Value <= ALTO.Value) do begin vWeekDay := LongDayNames[DayOfWeek(ALDATE.Value)]; if (vWeekDay = 'Sunday') then ALSUN.VALUE := ALSUN.VALUE + 1 else ALTOTAL.Value := ALTOTAL.Value + 1; ALDATE.Value := ALDATE.Value + 1; end; end;