首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

自画cxgrid表格,当关闭第二窗口时出现部分空白怎么解决

2012-09-01 
自画cxgrid表格,当关闭第二窗口时出现部分空白如何解决?由于cxgrid只画出记录条数的表格线,当记录不满一表

自画cxgrid表格,当关闭第二窗口时出现部分空白如何解决?
由于cxgrid只画出记录条数的表格线,当记录不满一表格时特别难看,所以我想通过自画把空白的部分补齐,但是补齐后当表格窗口前面打开另一个比表格小的窗口。当此窗口关闭后,会在cxgrid表格上留下一个原关闭窗口的空白影子,只有刷新表格后空白影子才消失。截图:


是在cxgrid的cxgrdtab1CustomDrawCell中调用
画表格代码:

C# code
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;




[解决办法]
我把你的代码贴到DrawCell中运行,关闭第二个窗口不会出现你说的情况啊
[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]
[解决办法]
那你关闭窗口的时候 自动刷新一下不行吗

这个东西资料少。还没有用过。。。


[解决办法]
没用过啊。
[解决办法]
呃......这个不是delphi的控件吗,怎么发到asp.net的地方来了

热点排行