W
whyme
Unregistered / Unconfirmed
GUEST, unregistred user!
自己做了一个控件,然后在处理时碰到了点问题,请看下面:
控件在 .dfm 中的代码:
object Form5: TForm5
Left = 192
Top = 107
Width = 715
Height = 543
Caption = 'Form5'
Color = clBtnFace
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = #23435#20307
Font.Style = []
OldCreateOrder = False
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 12
object Button1: TButton
Left = 602
Top = 246
Width = 95
Height = 49
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object qdMDEditors1: TqdMDEditors
Left = 8
Top = 8
Width = 585
Height = 489
BevelOuter = bvNone
Caption = 'qdMDEditors1'
TabOrder = 1
qdConnection = ADOConnection1
qdTreeView.Left = 0
qdTreeView.Top = 0
qdTreeView.Width = 585
qdTreeView.Height = 489
qdTreeView.Align = alClient
qdTreeView.BevelOuter = bvNone
qdTreeView.Caption = 'qdTreeView1'
qdTreeView.TabOrder = 0
qdTreeView.qdTreeView.Left = 0
qdTreeView.qdTreeView.Top = 22
qdTreeView.qdTreeView.Width = 120
qdTreeView.qdTreeView.Height = 447
qdTreeView.qdTreeView.Align = alClient
qdTreeView.qdTreeView.HideSelection = False
qdTreeView.qdTreeView.Indent = 19
qdTreeView.qdTreeView.ReadOnly = True
qdTreeView.qdTreeView.RightClickSelect = True
qdTreeView.qdTreeView.TabOrder = 2
qdTreeView.qdStatusBar.Left = 0
qdTreeView.qdStatusBar.Top = 469
qdTreeView.qdStatusBar.Width = 585
qdTreeView.qdStatusBar.Height = 20
qdTreeView.qdStatusBar.Panels = <
item
Text = #20934#22791#23601#32490
Width = 50
end>
qdTreeView.qdStatusBar.SimplePanel = False
qdTreeView.qdDBGridCaption = #24403#21069#20849#26377' 0 '#26465#25968#25454
qdTreeView.qdDBGridCaptionVisible = True
qdTreeView.qdTreeViewCaption = #26641#24418#25968#25454#21015#34920
qdTreeView.qdShowStatusBar = True
qdTreeView.qdTreeViewCaptionVisible = True
//注意这边,主要在这边
qdTreeView.qdAutoLoadTree = True
qdTreeView.qdRootText = #25968#25454#21015#34920
qdTreeView.qdATreeNodes = <>
qdTreeView.qdBTreeNodes = <
item
qdID = '1'
qdFatherID = '0'
qdLabel = 'Label1'
end>
qdTreeView.qdTreeViewVisible = True
qdTreeView.qdLeftWidth = 120
qdTreeView.qdStatusCaption = #20934#22791#23601#32490
end
object Button2: TButton
Left = 608
Top = 312
Width = 81
Height = 33
Caption = 'Button2'
TabOrder = 2
OnClick = Button2Click
end
object Button3: TButton
Left = 608
Top = 352
Width = 81
Height = 33
Caption = 'Button3'
TabOrder = 3
OnClick = Button3Click
end
object Button4: TButton
Left = 608
Top = 400
Width = 81
Height = 41
Caption = 'Button4'
TabOrder = 4
OnClick = Button4Click
end
object ADOConnection1: TADOConnection
Connected = True
ConnectionString =
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=I:/my/'#31243#24207#28304#30721'/'#32452#20214#36164#28304#24211'/Bp' +
'l '#24211'/qdControls/samples/001.MDB;Persist Security Info=False'
LoginPrompt = False
Mode = cmShareDenyNone
Provider = 'Microsoft.Jet.OLEDB.4.0'
Left = 622
Top = 80
end
object ImageList1: TImageList
Left = 642
Top = 144
end
object ADOTable1: TADOTable
Connection = ADOConnection1
TableName = #32852#31995#20154
Left = 616
Top = 24
end
end
控件中属性 qdAutoLoadTree 定义如下:
Property qdAutoLoadTree : Boolean Read FAutoLoadTree Write SetAutoLoadTree;
SetAutoLoadTree 是一个过程,设置 FAutoLoadTree 的值。
procedure SetAutoLoadTree(Value : Boolean);
begin
FAutoLoadTree := Value;
//??????????????
//.............
//这边进行判断 qdBTreeNodes 中的集合
//?????????????????
end;
现在碰到的问题如下:
1、看上面的代码,可知控件 qdMDEditors1.qdTreeView.qdBTreeNodes 的这个节点是存在且里面有集合的。
2、现在我在控件的一个属性 qdMDEditors1.qdTreeView.qdAutoLoadTree 为 True 时要读取qdMDEditors1.qdTreeView.qdBTreeNodes 中集合的值,但读不到。即在 SetAutoLoadTree 的事件中来读取 qdMDEditors1.qdTreeView.qdBTreeNodes 集合的值,但读不到。
3、仔细的分析了一下原因,应该是出在在读属性 qdAutoLoadTree 时,qdBTreeNodes这个属性还没读取(从.dfm 代码的前后来看),直接修改 .dfm 代码,把 qdTreeView.qdAutoLoadTree = False
这一句移到qdBTreeNodes的后面去,则正常了。
如下:
(前面省略)
..................
qdTreeView.qdRootText = #25968#25454#21015#34920
qdTreeView.qdATreeNodes = <>
qdTreeView.qdBTreeNodes = <
item
qdID = '1'
qdFatherID = '0'
qdLabel = 'Label1'
end>
qdTreeView.qdTreeViewVisible = True
//这一句从上面移到 qdBTreeNodes 的下面来,则可以正常,说明肯定是读取的先后顺序而引起的了。
qdTreeView.qdAutoLoadTree = True
...........
(后面省略)
现在问题来了:
象上面这种情况,我们没办法判断它 qdAutoLoadTree 会放在 qdBTreeNodes 的前或后,那如何在 SetAutoLoadTree 事件触发时,再触发系统自动去先从 .dfm 去读取 qdBtreeNodes 属性回来呢? 即如何保证在 SetAutoLoadTree 事件中能够读到 qdBTreeNodes 中的集合呢?
控件在 .dfm 中的代码:
object Form5: TForm5
Left = 192
Top = 107
Width = 715
Height = 543
Caption = 'Form5'
Color = clBtnFace
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = #23435#20307
Font.Style = []
OldCreateOrder = False
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 12
object Button1: TButton
Left = 602
Top = 246
Width = 95
Height = 49
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object qdMDEditors1: TqdMDEditors
Left = 8
Top = 8
Width = 585
Height = 489
BevelOuter = bvNone
Caption = 'qdMDEditors1'
TabOrder = 1
qdConnection = ADOConnection1
qdTreeView.Left = 0
qdTreeView.Top = 0
qdTreeView.Width = 585
qdTreeView.Height = 489
qdTreeView.Align = alClient
qdTreeView.BevelOuter = bvNone
qdTreeView.Caption = 'qdTreeView1'
qdTreeView.TabOrder = 0
qdTreeView.qdTreeView.Left = 0
qdTreeView.qdTreeView.Top = 22
qdTreeView.qdTreeView.Width = 120
qdTreeView.qdTreeView.Height = 447
qdTreeView.qdTreeView.Align = alClient
qdTreeView.qdTreeView.HideSelection = False
qdTreeView.qdTreeView.Indent = 19
qdTreeView.qdTreeView.ReadOnly = True
qdTreeView.qdTreeView.RightClickSelect = True
qdTreeView.qdTreeView.TabOrder = 2
qdTreeView.qdStatusBar.Left = 0
qdTreeView.qdStatusBar.Top = 469
qdTreeView.qdStatusBar.Width = 585
qdTreeView.qdStatusBar.Height = 20
qdTreeView.qdStatusBar.Panels = <
item
Text = #20934#22791#23601#32490
Width = 50
end>
qdTreeView.qdStatusBar.SimplePanel = False
qdTreeView.qdDBGridCaption = #24403#21069#20849#26377' 0 '#26465#25968#25454
qdTreeView.qdDBGridCaptionVisible = True
qdTreeView.qdTreeViewCaption = #26641#24418#25968#25454#21015#34920
qdTreeView.qdShowStatusBar = True
qdTreeView.qdTreeViewCaptionVisible = True
//注意这边,主要在这边
qdTreeView.qdAutoLoadTree = True
qdTreeView.qdRootText = #25968#25454#21015#34920
qdTreeView.qdATreeNodes = <>
qdTreeView.qdBTreeNodes = <
item
qdID = '1'
qdFatherID = '0'
qdLabel = 'Label1'
end>
qdTreeView.qdTreeViewVisible = True
qdTreeView.qdLeftWidth = 120
qdTreeView.qdStatusCaption = #20934#22791#23601#32490
end
object Button2: TButton
Left = 608
Top = 312
Width = 81
Height = 33
Caption = 'Button2'
TabOrder = 2
OnClick = Button2Click
end
object Button3: TButton
Left = 608
Top = 352
Width = 81
Height = 33
Caption = 'Button3'
TabOrder = 3
OnClick = Button3Click
end
object Button4: TButton
Left = 608
Top = 400
Width = 81
Height = 41
Caption = 'Button4'
TabOrder = 4
OnClick = Button4Click
end
object ADOConnection1: TADOConnection
Connected = True
ConnectionString =
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=I:/my/'#31243#24207#28304#30721'/'#32452#20214#36164#28304#24211'/Bp' +
'l '#24211'/qdControls/samples/001.MDB;Persist Security Info=False'
LoginPrompt = False
Mode = cmShareDenyNone
Provider = 'Microsoft.Jet.OLEDB.4.0'
Left = 622
Top = 80
end
object ImageList1: TImageList
Left = 642
Top = 144
end
object ADOTable1: TADOTable
Connection = ADOConnection1
TableName = #32852#31995#20154
Left = 616
Top = 24
end
end
控件中属性 qdAutoLoadTree 定义如下:
Property qdAutoLoadTree : Boolean Read FAutoLoadTree Write SetAutoLoadTree;
SetAutoLoadTree 是一个过程,设置 FAutoLoadTree 的值。
procedure SetAutoLoadTree(Value : Boolean);
begin
FAutoLoadTree := Value;
//??????????????
//.............
//这边进行判断 qdBTreeNodes 中的集合
//?????????????????
end;
现在碰到的问题如下:
1、看上面的代码,可知控件 qdMDEditors1.qdTreeView.qdBTreeNodes 的这个节点是存在且里面有集合的。
2、现在我在控件的一个属性 qdMDEditors1.qdTreeView.qdAutoLoadTree 为 True 时要读取qdMDEditors1.qdTreeView.qdBTreeNodes 中集合的值,但读不到。即在 SetAutoLoadTree 的事件中来读取 qdMDEditors1.qdTreeView.qdBTreeNodes 集合的值,但读不到。
3、仔细的分析了一下原因,应该是出在在读属性 qdAutoLoadTree 时,qdBTreeNodes这个属性还没读取(从.dfm 代码的前后来看),直接修改 .dfm 代码,把 qdTreeView.qdAutoLoadTree = False
这一句移到qdBTreeNodes的后面去,则正常了。
如下:
(前面省略)
..................
qdTreeView.qdRootText = #25968#25454#21015#34920
qdTreeView.qdATreeNodes = <>
qdTreeView.qdBTreeNodes = <
item
qdID = '1'
qdFatherID = '0'
qdLabel = 'Label1'
end>
qdTreeView.qdTreeViewVisible = True
//这一句从上面移到 qdBTreeNodes 的下面来,则可以正常,说明肯定是读取的先后顺序而引起的了。
qdTreeView.qdAutoLoadTree = True
...........
(后面省略)
现在问题来了:
象上面这种情况,我们没办法判断它 qdAutoLoadTree 会放在 qdBTreeNodes 的前或后,那如何在 SetAutoLoadTree 事件触发时,再触发系统自动去先从 .dfm 去读取 qdBtreeNodes 属性回来呢? 即如何保证在 SetAutoLoadTree 事件中能够读到 qdBTreeNodes 中的集合呢?