delphi – 当隐藏一列时,VirtualStringTree列应采用大小
发布时间:2020-12-15 09:50:35 所属栏目:大数据 来源:网络整理
导读:我有一个3列的VST,可以均匀占用可用空间. (我在Header.Options和中设置了hoAutoSpring 所有列都有Column [x].选项设置了coAutoSpring.) 现在我希望能够隐藏最后一列并保持其他列均匀占用空闲空间(有点像alClient控件). 当我只将列设置为不可见(见下文)时,该
我有一个3列的VST,可以均匀占用可用空间.
(我在Header.Options和中设置了hoAutoSpring 现在我希望能够隐藏最后一列并保持其他列均匀占用空闲空间(有点像alClient控件). 当我只将列设置为不可见(见下文)时,该列占用的空间就不再使用了. VST.Header.Columns[2].Options:=VST.Header.Columns[2].Options - [coVisible]; 当我将Header.Options.hoAutoResize设置为True并将Header.AutoSizeIndex设置为1时,第二列将占用所有新空间. 是否有方法告诉列填充可用空间并均匀调整大小? 截图: 解决方法
感谢所有人为您提供快速,高质量的回复!
由于似乎没有内置的方法来解决我的问题,我已经编码了以下方式(以防万一有人遇到类似的问题): // Show/hide a column and spread the space on all other visible columns // so that the proportions remain the same (as if AutoSpring was used) procedure ChangeColumnVisibility(Tree: TVirtualStringTree; Column: TColumnIndex; NewVisible: boolean); var Col : TVirtualTreeColumn; begin Col:=Tree.Header.Columns[Column]; if not (NewVisible xor (coVisible in Col.Options)) then Exit; if not NewVisible then begin Col.Options:=Col.Options - [coVisible]; Tree.Header.ResizeColumns(Col.Width,Tree.Header.Columns.Count-1); end else begin Tree.Header.ResizeColumns(-Col.Width,Tree.Header.Columns.Count-1); Col.Options:=Col.Options + [coVisible]; end; end; procedure TForm1.Button1Click(Sender: TObject); begin ChangeColumnVisibility(VST,2,not (coVisible in VST.Header.Columns[2].Options)); end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |