怎么能让 动态加载的控件在 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)弄到前面还是显示不出来。。望高人们给点提示~ 谢谢

解决方案 »

  1.   


    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 
      

  2.   

     
    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 
      

  3.   

    楼上的代码 我各种试了 还是显示不出来了 我在FORMload 里面
    Set Command1(0).Container = Frame1
    在FUNCTION 里面直接
    .Container = Frm_Input.Command1(0).Container
    没弄明白 = =
      

  4.   

    应该是层的关系with objButton
        '...
        .ZOrder
    end with
      

  5.   

    fvflove
    是这个意思么
    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 层的问题 研究了 也显示不出来了
    跟 控件的添加顺序有关系么 手动添加的控件就能显示出来 为什么动态的就不好用呢? 
      

  6.   


    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
      

  7.   

     .ZOrder
    也不好用 是不是我其他地方有问题?
      

  8.   

    如果还是有问题: 
    1.请确认你的控件的LEFT坐标,与TOP坐标. 
    2.确认控件所有容器的HEIGHT与WIDTH. 
    3.LEFT坐标或TOP坐标为负值.或大于HEIGHT或WIDTH 那怎么也看不见控件的.
      

  9.   

    坐标 什么的都没问题 没加FREAM 之前 都能正常生成 位置也对 就是 加了 fream 后 就显示不出来了 PICTUREBOX也显示不出来。
      

  10.   


    '我调试了一下.发现有以下问题:你自己改一下按扭位置的算法吧.因为是你按扭位置不对.
    '我将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