在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
在ERP实现排程的模块中,我们希望能直观展现个机台每天的排单情况,一直苦恼Delphi没有合适的控件,没办法,先自己动手。 效果图: 绘制日历关键代码 procedure TForm1.DrawCalender; var iDay, iProcess, days: Integer; row,col:Integer; begin //sgCalender. days := DaysInAMonth(StrToInt(cbbYear.Text), StrToInt(cbbMonth.Text)); sgCalender.ColCount := days + 1; sgCalender.RowCount := MachineNumber+1; sgCalender.RowHeights[0]:= 25; sgCalender.ColWidths[0]:= 80; for iDay := 1 to days do begin sgCalender.Cells[iDay, 0] := IntToStr(iDay); end; for iProcess := 1 to MachineNumber do begin sgCalender.Cells[0, iProcess] := '機台' + IntToStr(iProcess); end; for row := 1 to MachineNumber do begin for col := 1 to days do begin sgCalender.Cells[col, row] := Format('排單數:%d' + '|' + '完成數:%d'+ '|' + '製成率:%d',[Random(10000),Random(10000),Random(100)]) ; end; end; end;
在做的时候,由于cell内容不能换行,所以需要在DrawCell处理一下 procedure TForm1.sgCalenderDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var s, item: string; d: TStringGrid; I,num: Integer; begin d := TStringGrid(sender); s := d.Cells[ACol, ARow]; begin d.Canvas.Font.Assign(d.Font); //制定字体 with d.Canvas do begin Brush.Color := clWindow; //制定单元格颜色 if gdFixed in State then Brush.Color := d.FixedColor; Font.Color := clWindowText; FillRect(Rect); with d do begin num:=0; |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论