创新:cxGrid通过修改源码,不用band显示固定列显示(100)

  • 主题发起人 ourtibet
  • 开始时间
O

ourtibet

Unregistered / Unconfirmed
GUEST, unregistred user!
cxgrid如果要实现固定列,必须定义band来实现,不像dbgrideh那么简单,在cxgrid v4.5中显示效果也不好,通过研究源代码发现 在cxgridtableview.pas中给TcxGridTableViewInfo定义一个FixedLeft属性,同时修改一下代码:function TcxGridTableViewInfo.GetScrollableAreaBoundsHorz: TRect;begin Result := inherited GetScrollableAreaBoundsHorz; Dec(Result.Top, HeaderViewInfo.Height); Inc(Result.Bottom, FooterViewInfo.Height); //add by me if FFixedLeft>0 then Result.Left:=FFixedLeft;end;如果想要第一列固定,这么设置属性:GridView.ViewInfo.FixedLeft:=GridView.Columns[0].Width 即可达到固定列的效果只是有一个问题,当前选中行在滚动后位置会串位,应该是当前行滚动后需要加一个间距,但是暂时没有解决,哪位大虾对这个熟一些,往给予指导,给大家提供一种新的思路。
 
O

ourtibet

Unregistered / Unconfirmed
GUEST, unregistred user!
定义FixedLeft不是好办法,可以定义FixedCols传入需要固定的列,GetScrollableAreaBoundsHorz返回时加上固定列每个列的宽度就很方便了。大家测试的话,在返回值加上100就能看出效果function TcxGridTableViewInfo.GetScrollableAreaBoundsHorz: TRect;begin Result := inherited GetScrollableAreaBoundsHorz; Dec(Result.Top, HeaderViewInfo.Height); Inc(Result.Bottom, FooterViewInfo.Height); //add by me Result.Left:=Result.Left+100;end;测试一下选中行的串位问题
 
C

cnhotel

Unregistered / Unconfirmed
GUEST, unregistred user!
关注这个创新,谢谢分享。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
568
import
I
顶部