我在 form1 上放置了一个 VirtualStringTree(VST1) 并在其中添加了一些数据。无论节点数量如何,垂直滚动条都是可见的,并且我没有对节点高度的默认属性做任何事情。然后我将 VST1 复制到 form2 并将其命名为 VST2 并且 VST2 的滚动条不再可见。我改变了VST2的parent
控件和align
属性(我测试了很多次,不记得改变align和它的父属性的顺序),我不知道滚动条最后是如何显示的。然后我将 VST2 复制到 form3 并将其命名为 VST3。现在,无论我如何测试,当 VST3 中的数据超出其窗口视图时,它的垂直滚动条都无法看到。
VST的属性太多,应该设置哪些属性?
编辑:
// vt is on form1, scrollbaroption.alwaysvisible:=false;
// and vt can show vertical scrollbar,
object vt: TVirtualStringTree
Left = 1
Top = 1
Width = 353
Height = 301
Hint = 'Click header to sort'
Align = alClient
Header.AutoSizeIndex = 0
Header.DefaultHeight = 17
Header.Font.Charset = DEFAULT_CHARSET
Header.Font.Color = clWindowText
Header.Font.Height = -11
Header.Font.Name = 'MS Sans Serif'
Header.Font.Style = []
Header.Options = [hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible]
Indent = 3
ParentShowHint = False
ShowHint = True
TabOrder = 3
TreeOptions.MiscOptions = [toAcceptOLEDrop, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
TreeOptions.PaintOptions = [toShowRoot, toThemeAware, toUseBlendedImages]
TreeOptions.SelectionOptions = [toFullRowSelect, toMultiSelect, toRightClickSelect]
OnChange = vtChange
OnCompareNodes = vtCompareNodes
OnFocusChanged = vtFocusChanged
OnFreeNode = vtFreeNode
OnGetText = vtGetText
OnGetNodeDataSize = vtGetNodeDataSize
OnHeaderClick = vtHeaderClick
OnLoadNode = vtLoadNode
OnSaveNode = vtSaveNode
Columns = <
item
Position = 0
Width = 168
WideText = 'Type'
end
item
Position = 1
Width = 80
WideText = 'Frequency'
end
item
Position = 2
Width = 80
WideText = 'Percent'
end
item
CheckBox = True
Position = 3
Width = 80
WideText = 'Rank'
end
item
Position = 4
Width = 80
WideText = 'Length'
end
item
Position = 5
WideText = 'Syllables'
end
item
Position = 6
end>
end
end
//tfvt is on form2, scrollbaroption.alwaysvisible:=true;
// I tested both scrollbaroption.alwaysvisible:=true and false
// yesterday it showed scrollbar, today it does not.
// tfvt does not show vertical scrollbar.
object tfvt: TVirtualStringTree
Left = 1
Top = 138
Width = 737
Height = 227
Hint = 'Click header to sort'
Align = alClient
Header.AutoSizeIndex = 0
Header.DefaultHeight = 17
Header.Font.Charset = DEFAULT_CHARSET
Header.Font.Color = clWindowText
Header.Font.Height = -11
Header.Font.Name = 'MS Sans Serif'
Header.Font.Style = []
Header.Options = [hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible]
Indent = 3
ParentShowHint = False
ScrollBarOptions.AlwaysVisible = True
ShowHint = True
TabOrder = 2
TreeOptions.MiscOptions = [toAcceptOLEDrop, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
TreeOptions.PaintOptions = [toShowRoot, toThemeAware, toUseBlendedImages]
TreeOptions.SelectionOptions = [toFullRowSelect, toMultiSelect, toRightClickSelect]
OnChange = tfvtChange
OnCompareNodes = tfvtCompareNodes
OnFocusChanged = tfvtFocusChanged
OnFocusChanging = tfvtFocusChanging
OnFreeNode = tfvtFreeNode
OnGetText = tfvtGetText
OnGetNodeDataSize = tfvtGetNodeDataSize
OnHeaderClick = tfvtHeaderClick
OnLoadNode = tfvtLoadNode
OnSaveNode = tfvtSaveNode
Columns = <
item
Position = 0
Width = 80
end
item
Position = 1
Width = 80
end
item
Position = 2
Width = 80
end
item
CheckBox = True
Position = 3
Width = 80
end
item
Position = 4
Width = 80
end
item
Position = 5
Width = 80
end
item
Position = 6
Width = 80
end>
end
end
end
end
// kwicvt is on form3, scrollbaroption.alwaysvisible:=true;
// I tested both scrollbaroption.alwaysvisible:=true and false
// Now kwicvt does not show vertical scrollbar.
//
object kwicvt: TVirtualStringTree
Left = 32
Top = 24
Width = 433
Height = 317
Hint = 'Click header to sort'
Header.AutoSizeIndex = 0
Header.DefaultHeight = 17
Header.Font.Charset = DEFAULT_CHARSET
Header.Font.Color = clWindowText
Header.Font.Height = -11
Header.Font.Name = 'MS Sans Serif'
Header.Font.Style = []
Header.Options = [hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible]
Indent = 3
ParentShowHint = False
ShowHint = True
TabOrder = 0
TreeOptions.AnimationOptions = [toAnimatedToggle]
TreeOptions.MiscOptions = [toAcceptOLEDrop, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
TreeOptions.PaintOptions = [toShowRoot, toThemeAware, toUseBlendedImages]
TreeOptions.SelectionOptions = [toFullRowSelect, toMultiSelect, toRightClickSelect]
OnChange = kwicvtChange
OnCompareNodes = kwicvtCompareNodes
OnFocusChanged = kwicvtFocusChanged
OnFreeNode = kwicvtFreeNode
OnGetText = kwicvtGetText
OnGetNodeDataSize = kwicvtGetNodeDataSize
OnHeaderClick = kwicvtHeaderClick
OnLoadNode = kwicvtLoadNode
OnSaveNode = kwicvtSaveNode
Columns = <
item
Position = 0
Width = 80
end
item
Alignment = taRightJustify
Position = 1
Width = 80
end
item
Alignment = taCenter
Position = 2
Width = 80
end
item
CheckBox = True
Position = 3
Width = 80
end
item
Position = 4
Width = 80
end
item
Position = 5
Width = 80
end
item
Position = 6
Width = 80
end>
end
[编辑]:
先谢谢了。
我仔细测试发现,如果我多次调用同一个函数,从第二次开始,就会出现那个virticalscrollbar。就像是:
function fill;
begin
// filling VST;
end;
function button1click;
begin
fill;
end;
我第一次点击button1,没有出现verticalscrollbar;如果是第二次或更多次,则显示完美。
为什么?,如何解决?
谢谢