大佬教程收集整理的这篇文章主要介绍了delphi – 将图形栏添加到StringGrid col,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我正在做的一个简单的例子
//设置网格
procedure TGriddata.FormCreate(Sender: TObject); begin grdMain.Rows[0].commatext:='"One","Two","Three","Four","Five"'; grdMain.ColWidths[0]:= 50; grdMain.ColWidths[1]:= 175; grdMain.ColWidths[2]:= 175; grdMain.ColWidths[3]:= 100; grdMain.ColWidths[4]:= 300; end;
//在网格中显示数据
//注意,我没有显示我的查询的创建,执行或销毁
procedure TGriddata.load; begin ... grdMain.Cells[0,row]:= FieldByName('one').AsString; grdMain.Cells[1,row]:= FieldByName('two').AsString; grdMain.Cells[2,row]:= FieldByName('three').AsString; grdMain.Cells[3,row]:= FieldByName('four').AsString; //draw progress bar here ... end;
其中一列(“五”)需要在col中显示海军蓝色水平条.它还应该显示一些以栏为中心的文本.我没有使用自定义绘图的经验.我设置的哪些属性只能自定义绘制一列并使用其他列的默认绘图?
procedure TForm1.grdMainDrawCell(Sender: TObject; ACol,ARow: Integer; Rect: TRect; State: TGridDrawStatE); var Progress: Single; R: TRect; Txt: String; begin with TStringGrid(Sender) do if (ACol = 4) And (ARow >= FixedRows) then begin Progress := StrToFloatDef(Cells[ACol,ARow],0) / 100; Canvas.FillRect(Rect); R := Rect; R.Right := R.Left + Trunc((R.Right - R.Left) * Progress); Canvas.brush.Color := clNavy; Canvas.Rectangle(R); Txt := Cells[ACol,ARow] + '%'; Canvas.brush.Style := bsClear; IntersectClipRect(Canvas.Handle,R.Left,R.Top,R.Right,R.bottom); Canvas.Font.Color := clHighlightText; DrawText(Canvas.Handle,PChar(Txt),-1,Rect,DT_SINGLELINE or DT_CENTER or DT_VCENTER or DT_END_ELLIPSIS or DT_NOPREFIX); SELEctClipRgn(Canvas.Handle,0); ExcludeClipRect(Canvas.Handle,R.bottom); Canvas.Font.Color := clWindowText; DrawText(Canvas.Handle,0); end; end;
有关更多选项,您可以考虑this DrawStatus
routine.
以上是大佬教程为你收集整理的delphi – 将图形栏添加到StringGrid col全部内容,希望文章能够帮你解决delphi – 将图形栏添加到StringGrid col所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。