3
我使用Delphi XE,我想使標準ListView的行爲看起來像我想要的。 我想列表視圖是vsReport,所以我可以爲我的項目組。 在設計時,我爲每個組創建了列(名爲Topic的一列),兩個組和幾個項目。如何防止ListView標題遮擋第一組的頂部?
在設計時,ListView看起來不錯,但是在運行時,我的第一組在某種程度上隱藏在列標題下。以下是圖像:
在設計時:
在運行時:
,這裏是我的DFM
object Form2: TForm2
Left = 326
Top = 150
Caption = 'Form2'
ClientHeight = 636
ClientWidth = 1289
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object ListView1: TListView
Left = 0
Top = 0
Width = 205
Height = 636
Align = alLeft
Columns = <
item
Caption = 'Topic'
Width = 200
end>
ColumnClick = False
DoubleBuffered = True
FullDrag = True
Groups = <
item
Header = 'First group'
GroupID = 0
State = []
HeaderAlign = taLeftJustify
FooterAlign = taLeftJustify
Subtitle = 'Options bellow'
TitleImage = 1
end
item
Header = 'Settings'
GroupID = 1
State = [lgsNormal]
HeaderAlign = taLeftJustify
FooterAlign = taLeftJustify
Subtitle = 'Other options here'
TitleImage = 0
end>
HideSelection = False
HotTrack = True
HotTrackStyles = [htUnderlineCold, htUnderlineHot]
Items.ItemData = {
059E000000030000000000000000000000FFFFFFFF0000000000000000000000
000A4600690072007300740020006900740065006D000100000001000000FFFF
FFFF0000000000000000000000000B5300650063006F006E0064002000690074
0065006D000200000002000000FFFFFFFF000000000100000000000000134600
69007300720074002000730065007400740069006E0067007300200069007400
65006D00}
GroupView = True
RowSelect = True
ParentDoubleBuffered = False
ShowWorkAreas = True
TabOrder = 0
ViewStyle = vsReport
OnClick = ListView1Click
ExplicitTop = 8
ExplicitHeight = 497
end
end
如何防止這種情況發生?
的'RecreateWnd()'上只是'TListView'就足夠了。改變'ViewStyle'是矯枉過正的,正如重新創建Form窗口及其所有子控件一樣。 –
謝謝你們兩位。雷米Lebeau,您的評論也非常有幫助。謝謝 – user1137313
作爲一個測試,我創建了一個'TForm',它的'CreateWnd()'方法直接調用與'TListView'相同的API,並且生成的ListView不會出現問題。很奇怪。也許有一些額外的'TListView'正在干擾底層窗口,以管理其內容相對於其內置頭控件的方式。 –