怎么能让 动态加载的控件在 FORM以外的控件上显示。
下面是 动态加载控件的代码
[code={VB}]
Public Function CreatButton(ByVal x As Long, ByVal y As Long, _
ByVal i As Integer, ByVal B_caption As String, ByVal Tags As String)
Dim ObjButton Load Frm_Input.Command1(i)
Set ObjButton = Frm_Input.Command1(i)
With ObjButton
.Caption = Trim$(B_caption)
.Visible = True
.Left = x
.Top = y
.Tag = Tags
End With
End Function
[/code]
在FORM上放个控件(比如picturebox)动态添加的控件就显示不到了
我把LOAD的 的控件 INDEX (0)的按钮也放到picturebox 上面 生成的控件就是显示不了。。 是层的关系么。
我把LOAD的 的控件 INDEX (0)弄到前面还是显示不出来。。望高人们给点提示~ 谢谢
下面是 动态加载控件的代码
[code={VB}]
Public Function CreatButton(ByVal x As Long, ByVal y As Long, _
ByVal i As Integer, ByVal B_caption As String, ByVal Tags As String)
Dim ObjButton Load Frm_Input.Command1(i)
Set ObjButton = Frm_Input.Command1(i)
With ObjButton
.Caption = Trim$(B_caption)
.Visible = True
.Left = x
.Top = y
.Tag = Tags
End With
End Function
[/code]
在FORM上放个控件(比如picturebox)动态添加的控件就显示不到了
我把LOAD的 的控件 INDEX (0)的按钮也放到picturebox 上面 生成的控件就是显示不了。。 是层的关系么。
我把LOAD的 的控件 INDEX (0)弄到前面还是显示不出来。。望高人们给点提示~ 谢谢
Public Function CreatButton(ByVal x As Long, ByVal y As Long, _
ByVal i As Integer, ByVal B_caption As String, ByVal Tags As String)
Dim ObjButton Load Frm_Input.Command1(i)
Set ObjButton = Frm_Input.Command1(i)
With ObjButton
.Caption = Trim$(B_caption)
.Visible = True
.Left = x
.Top = y
.Tag = Tags
.Container = Frm_Input.Command1(0).Container
End With
End Function
Public Function CreatButton(ByVal x As Long, ByVal y As Long, _
ByVal i As Integer, ByVal B_caption As String, ByVal Tags As String)
Dim ObjButton Load Frm_Input.Command1(i)
Set ObjButton = Frm_Input.Command1(i)
With ObjButton
.Caption = Trim$(B_caption)
.Visible = True
.Left = x
.Top = y
.Tag = Tags
End With
' set ObjButton.Container = form1 '加上此句.注意 form 是放command(0)的容器
End Function
Set Command1(0).Container = Frame1
在FUNCTION 里面直接
.Container = Frm_Input.Command1(0).Container
没弄明白 = =
'...
.ZOrder
end with
是这个意思么
Public Function CreatButton(ByVal x As Long, ByVal y As Long, _
ByVal i As Integer, ByVal B_caption As String, ByVal Tags As String)
Dim ObjButton Load Frm_Input.Command1(i)
Set ObjButton = Frm_Input.Command1(i)
Set ObjButton.Container = Frm_Input
With ObjButton
.Caption = Trim$(B_caption)
.Visible = True
.Left = x
.Top = y
.Tag = Tags
End With
Set ObjButton.Container = Frm_Input.Frame1End Function回FJ182 层的问题 研究了 也显示不出来了
跟 控件的添加顺序有关系么 手动添加的控件就能显示出来 为什么动态的就不好用呢?
Public Function CreatButton(ByVal x As Long, ByVal y As Long, _
ByVal i As Integer, ByVal B_caption As String, ByVal Tags As String)
Dim ObjButton
Load Frm_Input.Command1(i)
Set ObjButton = Frm_Input.Command1(i)
With ObjButton
.Caption = Trim$(B_caption)
.Visible = True
.Left = x
.Top = y
.Tag = Tags
.ZOrder
End With
End Function
也不好用 是不是我其他地方有问题?
1.请确认你的控件的LEFT坐标,与TOP坐标.
2.确认控件所有容器的HEIGHT与WIDTH.
3.LEFT坐标或TOP坐标为负值.或大于HEIGHT或WIDTH 那怎么也看不见控件的.
'我调试了一下.发现有以下问题:你自己改一下按扭位置的算法吧.因为是你按扭位置不对.
'我将CreatButton 中增加了一些调试代码..你可以看一下.Public Function CreatButton(ByVal x As Long, ByVal y As Long, _
ByVal i As Integer, ByVal B_caption As String, ByVal Tags As String)
Dim ObjButton
Load Frm_Input.Command1(i)
Set ObjButton = Frm_Input.Command1(i)
With ObjButton
.Caption = Trim$(B_caption)
.Visible = True
.Left = x
.Top = y
.Tag = Tags
.ZOrder
End With
MsgBox Frm_Input.Command1(i).Left '其中有一个是8130
MsgBox Frm_Input.Command1(i).Top '其中有一个是 345
MsgBox Frm_Input.Command1(i).Container.Name '其中有一个是 Frame1
MsgBox Frm_Input.Command1(i).Container.Width '其中有一个是 6975
Stop
'发现建立按扭的Left值大于容器 Frame1的宽度.因此看不见了.
' Set ObjButton.Container = Frm_Input.Frame1End Function