我正在使用firemonkey Delphi。我有一個 Grid 組件和一個串列框中的幾個編輯框,每個組件在串列框中占據自己的串列框項。我的問題是,當我滑動串列框并且我的滑鼠在網格組件上移動時,網格組件會捕獲我的滑鼠滾輪滾動而不是串列框。我想要實作的是滾動功能保留在串列框中,并且僅在單擊它/單元格時滾動網格。如果我將 grid hittest 設定為 false 它可以正常作業,但是如何檢測滑鼠何時位于網格組件上以捕獲任何 mousedown 事件以重新激活 Grid 以進行滾動?
這是我正在使用的表格
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 736
ClientWidth = 636
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
DesignerMasterStyle = 0
object ListBox1: TListBox
Align = Client
Size.Width = 636.000000000000000000
Size.Height = 736.000000000000000000
Size.PlatformDefault = False
TabOrder = 1
DisableFocusEffect = True
DefaultItemStyles.ItemStyle = ''
DefaultItemStyles.GroupHeaderStyle = ''
DefaultItemStyles.GroupFooterStyle = ''
Viewport.Width = 616.000000000000000000
Viewport.Height = 732.000000000000000000
object ListBoxItem1: TListBoxItem
Size.Width = 616.000000000000000000
Size.Height = 65.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
end
object ListBoxItem2: TListBoxItem
Position.Y = 65.000000000000000000
Size.Width = 616.000000000000000000
Size.Height = 65.000000000000000000
Size.PlatformDefault = False
TabOrder = 1
end
object ListBoxItem3: TListBoxItem
Position.Y = 130.000000000000000000
Size.Width = 616.000000000000000000
Size.Height = 65.000000000000000000
Size.PlatformDefault = False
TabOrder = 2
end
object ListBoxItem4: TListBoxItem
Position.Y = 195.000000000000000000
Size.Width = 616.000000000000000000
Size.Height = 65.000000000000000000
Size.PlatformDefault = False
TabOrder = 3
end
object ListBoxItem5: TListBoxItem
Position.Y = 260.000000000000000000
Size.Width = 616.000000000000000000
Size.Height = 500.000000000000000000
Size.PlatformDefault = False
TabOrder = 4
object Grid1: TGrid
Align = Client
CanFocus = True
ClipChildren = True
Size.Width = 616.000000000000000000
Size.Height = 500.000000000000000000
Size.PlatformDefault = False
TabOrder = 40
Viewport.Width = 596.000000000000000000
Viewport.Height = 475.000000000000000000
object Column1: TColumn
end
object Column2: TColumn
end
end
end
object ListBoxItem6: TListBoxItem
Position.Y = 760.000000000000000000
Size.Width = 616.000000000000000000
Size.Height = 65.000000000000000000
Size.PlatformDefault = False
TabOrder = 5
end
object ListBoxItem7: TListBoxItem
Position.Y = 825.000000000000000000
Size.Width = 616.000000000000000000
Size.Height = 65.000000000000000000
Size.PlatformDefault = False
TabOrder = 6
end
object ListBoxItem8: TListBoxItem
Position.Y = 890.000000000000000000
Size.Width = 616.000000000000000000
Size.Height = 65.000000000000000000
Size.PlatformDefault = False
TabOrder = 7
end
object ListBoxItem9: TListBoxItem
Position.Y = 955.000000000000000000
Size.Width = 616.000000000000000000
Size.Height = 65.000000000000000000
Size.PlatformDefault = False
TabOrder = 8
end
object ListBoxItem10: TListBoxItem
Position.Y = 1020.000000000000000000
Size.Width = 616.000000000000000000
Size.Height = 65.000000000000000000
Size.PlatformDefault = False
TabOrder = 9
end
object ListBoxItem11: TListBoxItem
Position.Y = 1085.000000000000000000
Size.Width = 616.000000000000000000
Size.Height = 65.000000000000000000
Size.PlatformDefault = False
TabOrder = 10
end
object ListBoxItem12: TListBoxItem
Position.Y = 1150.000000000000000000
Size.Width = 616.000000000000000000
Size.Height = 65.000000000000000000
Size.PlatformDefault = False
TabOrder = 11
end
end
end
uj5u.com熱心網友回復:
Grid1.DisableMouseWheel := True在設計器中設定屬性。
然后在Grid1Click片場Grid1.DisableMouseWheel := False和
再次ListBox1Click上場Grid1.DisableMouseWheel := True。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/424526.html
