把Frame.enabled设为False不就行了。

解决方案 »

  1.   

    如果纯粹不想对容器内的控件进行操作,可以使用楼上的做法。如果想把容器内的所有控件都“变灰”,就要把每个控件的enabled属性变false了。如果你觉得一个一个地改太痛苦的话,可以使用下面的方法:Public Sub EnableControls(mActiveForm As Form, mParent As Control, Optional bEnabled As Boolean = True)
                Dim ctl As Control
                For Each MyControl In mActiveForm.Controls
                    If MyControl.Parent.Name = mParent.Name Then
                        MyControl.Enabled=bEnabled
                    End If                
                Next
    End Sub
      

  2.   

    使用方法:失效(变灰):
    EnableControls Form1, Frame1, False生效(正常):
    EnableControls Form1, Frame1, True
      

  3.   

    Option Explicit楼上兄弟说的很对,不过设置Frame的Eabled为False,其中的控件外观看上去是有效的,可又不能点,容易产品疑惑。可以用我写的代码:
    '将Frame1中包含的控件的Eabled属性全部设为False.
    Private Sub Command1_Click()
    Dim ctl As Control
        For Each ctl In Me.Controls
            If ctl.Container.Name = "Frame1" Then
                ctl.Enabled = False
            End If
        Next
    End Sub
      

  4.   

    Private Sub Form_Activate()
    Dim x As Control
        For Each x In Controls
            x.Enabled = False
        Next x
    End Sub
      

  5.   

    Private Sub Form_Activate()
    Dim x As Control
        For Each x In Controls
            x.Enabled = False
        Next x
    End Sub 
      

  6.   


    帖主,对不起,我没有测试过,现在发现有严重问题,griefforyou(为你伤心) 的才是正确的,我另开帖子声明并把分给他们。
      

  7.   

    现在修正如下:
    函数:
    Public Sub EnableControls(mActiveForm As Form, mContainer As Control, Optional bEnabled As Boolean = True)
                Dim ctl As Control
                For Each MyControl In mActiveForm.Controls
                    If MyControl.Container.Name = mContainer.Name Then
                        MyControl.Enabled=bEnabled
                    End If              
                Next
    End Sub
    使用方法:失效(变灰):
    EnableControls Form1, Frame1, False生效(正常):
    EnableControls Form1, Frame1, True   帖子地址在:
    http://www.csdn.net/Expert/topic/420/420585.shtm