由于cxgrid只画出记录条数的表格线,当记录不满一表格时特别难看,所以我想通过自画把空白的部分补齐,但是补齐后当表格窗口前面打开另一个比表格小的窗口。当此窗口关闭后,会在cxgrid表格上留下一个原关闭窗口的空白影子,只有刷新表格后空白影子才消失。截图:
是在cxgrid的cxgrdtab1CustomDrawCell中调用
画表格代码:function DrawFullGrid(GridTableView: TcxCustomGridTableView;
ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo): Boolean;
var
i: Integer;
lMaxRow: Integer;
Rect1: TRect;
ABorder: TcxBorder;
begin
ACanvas.FillRect(AViewInfo.Bounds);
ACanvas.DrawText(AViewInfo.GridRecord.DisplayTexts[AViewInfo.Item.Index], AViewInfo.Bounds, cxAlignHCenter);
//计算最多画多少行
lMaxRow := AViewInfo.GridViewInfo.NoDataInfoTextAreaBounds.Bottom - AViewInfo.GridViewInfo.NoDataInfoTextAreaBounds.Top mod AViewInfo.Bounds.Bottom - AViewInfo.Bounds.Top + 2;
if AViewInfo.GridRecord.Index = GridTableView.ViewData.RecordCount - 1 then
begin
for i := GridTableView.ViewData.RecordCount + 1 to lMaxRow do
begin
//画表格
Rect1.Top := AViewInfo.Bounds.Top - 1 + (AViewInfo.Bounds.Bottom - AViewInfo.Bounds.Top) * (i - GridTableView.ViewData.RecordCount);
Rect1.Bottom := AViewInfo.Bounds.Bottom + (AViewInfo.Bounds.Bottom - AViewInfo.Bounds.Top) * (i - GridTableView.ViewData.RecordCount);
Rect1.Left := AViewInfo.Bounds.Left - 1;
Rect1.Right := AViewInfo.Bounds.Right + 1; if AViewInfo.GridView.Styles.Content <> nil then
ACanvas.Brush.Color := AViewInfo.GridView.Styles.Content.Color
else
ACanvas.Brush.Color := clWhite; if (i mod 2) = 0 then
if AViewInfo.GridView.Styles.ContentOdd <> nil then
ACanvas.Brush.Color := AViewInfo.GridView.Styles.ContentOdd.Color
else
if AViewInfo.GridView.Styles.ContentEven <> nil then
ACanvas.Brush.Color := AViewInfo.GridView.Styles.ContentEven.Color; ACanvas.FillRect(Rect1);
ACanvas.Brush.Color := AViewInfo.BorderColor[ABorder];
ACanvas.FrameRect(Rect1);
AViewInfo.GridViewInfo.Painter.ExcludeFromBackground(Rect1);
end;
end;
Result := True;
end;
是在cxgrid的cxgrdtab1CustomDrawCell中调用
画表格代码:function DrawFullGrid(GridTableView: TcxCustomGridTableView;
ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo): Boolean;
var
i: Integer;
lMaxRow: Integer;
Rect1: TRect;
ABorder: TcxBorder;
begin
ACanvas.FillRect(AViewInfo.Bounds);
ACanvas.DrawText(AViewInfo.GridRecord.DisplayTexts[AViewInfo.Item.Index], AViewInfo.Bounds, cxAlignHCenter);
//计算最多画多少行
lMaxRow := AViewInfo.GridViewInfo.NoDataInfoTextAreaBounds.Bottom - AViewInfo.GridViewInfo.NoDataInfoTextAreaBounds.Top mod AViewInfo.Bounds.Bottom - AViewInfo.Bounds.Top + 2;
if AViewInfo.GridRecord.Index = GridTableView.ViewData.RecordCount - 1 then
begin
for i := GridTableView.ViewData.RecordCount + 1 to lMaxRow do
begin
//画表格
Rect1.Top := AViewInfo.Bounds.Top - 1 + (AViewInfo.Bounds.Bottom - AViewInfo.Bounds.Top) * (i - GridTableView.ViewData.RecordCount);
Rect1.Bottom := AViewInfo.Bounds.Bottom + (AViewInfo.Bounds.Bottom - AViewInfo.Bounds.Top) * (i - GridTableView.ViewData.RecordCount);
Rect1.Left := AViewInfo.Bounds.Left - 1;
Rect1.Right := AViewInfo.Bounds.Right + 1; if AViewInfo.GridView.Styles.Content <> nil then
ACanvas.Brush.Color := AViewInfo.GridView.Styles.Content.Color
else
ACanvas.Brush.Color := clWhite; if (i mod 2) = 0 then
if AViewInfo.GridView.Styles.ContentOdd <> nil then
ACanvas.Brush.Color := AViewInfo.GridView.Styles.ContentOdd.Color
else
if AViewInfo.GridView.Styles.ContentEven <> nil then
ACanvas.Brush.Color := AViewInfo.GridView.Styles.ContentEven.Color; ACanvas.FillRect(Rect1);
ACanvas.Brush.Color := AViewInfo.BorderColor[ABorder];
ACanvas.FrameRect(Rect1);
AViewInfo.GridViewInfo.Painter.ExcludeFromBackground(Rect1);
end;
end;
Result := True;
end;
解决方案 »
- 动态生成的label之间如何加空格
- 如何设置Page 指令中会话状态
- c#和vb.net,初學者選用c#還是vb.net好
- 初学者的问题:如何将一个数字以,分隔开??
- asp.net中数据更新问题~~
- 淘宝购买后,别人根据订单自己提货的这个方法,是还需要淘宝公开平台么
- 字符串转为图片,图片有一半显示灰色
- 请帮我讲一个PetShop中SQLServerDAL.SQLHelper类中调用GetCachedParameters方法取参,有点看不懂。
- 急!本地运行正常,上传后为什么会出这种错?1.1版
- 如何动态修改删除dataset中datatable的数据?
- 又是MVC的问题。雷锋程序员们帮忙看看。。超级初级的问题问题等级LV1
- 如何写这样的sql
[code=Delphi(Pascal]
procedure TF_RolePopedom.cxGridDBTableView1CustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
i: Integer;
lMaxRow: Integer;
Rect1: TRect;
ABorder: TcxBorder;
begin
ACanvas.FillRect(AViewInfo.Bounds);
ACanvas.DrawText(AViewInfo.GridRecord.DisplayTexts[AViewInfo.Item.Index], AViewInfo.Bounds, cxAlignHCenter);
//计算最多画多少行
lMaxRow := AViewInfo.GridViewInfo.NoDataInfoTextAreaBounds.Bottom - AViewInfo.GridViewInfo.NoDataInfoTextAreaBounds.Top mod AViewInfo.Bounds.Bottom - AViewInfo.Bounds.Top + 2;
if AViewInfo.GridRecord.Index = cxGridDBTableView1.ViewData.RecordCount - 1 then
begin
for i := cxGridDBTableView1.ViewData.RecordCount + 1 to lMaxRow do
begin
//画表格
Rect1.Top := AViewInfo.Bounds.Top - 1 + (AViewInfo.Bounds.Bottom - AViewInfo.Bounds.Top) * (i - cxGridDBTableView1.ViewData.RecordCount);
Rect1.Bottom := AViewInfo.Bounds.Bottom + (AViewInfo.Bounds.Bottom - AViewInfo.Bounds.Top) * (i - cxGridDBTableView1.ViewData.RecordCount);
Rect1.Left := AViewInfo.Bounds.Left - 1;
Rect1.Right := AViewInfo.Bounds.Right + 1; if AViewInfo.GridView.Styles.Content <> nil then
ACanvas.Brush.Color := AViewInfo.GridView.Styles.Content.Color
else
ACanvas.Brush.Color := clWhite; if (i mod 2) = 0 then
if AViewInfo.GridView.Styles.ContentOdd <> nil then
ACanvas.Brush.Color := AViewInfo.GridView.Styles.ContentOdd.Color
else
if AViewInfo.GridView.Styles.ContentEven <> nil then
ACanvas.Brush.Color := AViewInfo.GridView.Styles.ContentEven.Color; ACanvas.FillRect(Rect1);
ACanvas.Brush.Color := AViewInfo.BorderColor[ABorder];
ACanvas.FrameRect(Rect1);
AViewInfo.GridViewInfo.Painter.ExcludeFromBackground(Rect1);
end;
end;
end;
[/code]