Enable属性改为false就行了

解决方案 »

  1.   

    MenuName.Enabled = False(或True)   ' 可能是Enable,不记得了。
      

  2.   

    可我找不到“菜单name”
    到哪去找这个对象?
      

  3.   

    不会吧,这样的问题现在还没有弄懂,"菜单name"就是在菜单编辑器中的名称。
      

  4.   

    菜单编辑器中你设计的名称,你的菜单有单击事件吗?***_clik中***!!!
      

  5.   

    不对吧。
    你们自己设计过吗?
    用的是Microsoft的Visual Basic 6.0吗?
      

  6.   

    to lxiwei,***的属性不包括Enable,
    不信你试试。
      

  7.   

    我可以在菜单编辑器中设置Enable,
    但是我需要在程序运行时设置。
      

  8.   

    那就在程序中把enable属性设为false呀。
    private command_click()
    mnufile.enable=false
    end sub
      

  9.   

    把下面保存  aa.frmVERSION 5.00
    Begin VB.Form Form1 
       Caption         =   "Form1"
       ClientHeight    =   3195
       ClientLeft      =   165
       ClientTop       =   735
       ClientWidth     =   4680
       LinkTopic       =   "Form1"
       ScaleHeight     =   3195
       ScaleWidth      =   4680
       StartUpPosition =   3  'Windows Default
       Begin VB.CommandButton Command2 
          Caption         =   "Command2"
          Height          =   495
          Left            =   1740
          TabIndex        =   1
          Top             =   1890
          Width           =   1215
       End
       Begin VB.CommandButton Command1 
          Caption         =   "Command1"
          Height          =   495
          Left            =   1740
          TabIndex        =   0
          Top             =   1350
          Width           =   1215
       End
       Begin VB.Menu a 
          Caption         =   "a"
          Begin VB.Menu aa 
             Caption         =   "aa"
          End
          Begin VB.Menu bb 
             Caption         =   "bb"
             Enabled         =   0   'False
          End
          Begin VB.Menu cc 
             Caption         =   "cc"
          End
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Private Sub Command1_Click()
        bb.Enabled = True
        cc.Enabled = False
    End SubPrivate Sub Command2_Click()
        bb.Enabled = False
        cc.Enabled = True
    End Sub
      

  10.   

    菜单编辑器中,第一栏是标题,第二栏是名称,
    你要Disable的菜单项的名称.Enabled=False
    比如你填的名称是:  MenuOK
    那么就是
    MenuOK.Enabled=False
      

  11.   

    例 文件-mnufile
       打开文件-mnufile_open
    private sub mnufile_open_click()
      mnufile_open.enabled=false
    End sub
      

  12.   

    菜单编辑器:
    名称:CurChannels
    有效:未button1:
    CurChannels.Enabled = True运行:
    按下button1结果:
    编译错误。
    未找到方法或数据成员。
      

  13.   

        For Each Control In Me.Controls
            If TypeOf Control Is Menu Then
                If ... then
                    Control.Enabled = True
                Else
                    Control.Enabled = False
                End If
            End If
        Next Control
    或者用API函数GetMenu()获得主菜单,载GetSubMenu获得子菜单
      

  14.   

    用下列语句:
       me.CurChannels.Enabled =False
    在输入me.时看看弹出的帮助框内是不是有CurChannels,若没有则说明你根本就没有CurChannels菜单,找到你自己需要的菜单名再来提问
      

  15.   

    joeking(天龙),我看不是这么来得,而是提问的人自己不努力,只想要别人告诉他怎么做,自己却不去试.
      

  16.   

    to hz1101有me.curChannels,
    但是curChannels后面没有enabled选项,只有
      count
      

  17.   

    count
    item
    lbound
    ubound
    四个选项。
      

  18.   

    to chenhw出现错误:
    “不能在该控件中加enabled属性。”
      

  19.   

    我认为RUSHING肯定是在骗人蹭分,(RUSHING,别砍我),呵呵,:)
      

  20.   

    也可能是VB系統出bug,我就經常輸入對象名而不能出現屬性.
    重裝VB就好啦.(不怪它怪誰?)
      

  21.   

    我也觉得很奇怪,怎么可能出现RUSHING说的情况呢?
      

  22.   

    rushing(),curChannels只有
    count
    item
    lbound
    ubound
    四个选项适因为curChannels是菜单数组.
    curChannels(0).Enabled=False
      

  23.   

    to Prefix
    你说的很有道理。
    我用curChannels(i).enabled 就可以赋值了。
    但是无论我将i设为0或1或curChannels.count,都出错:
    “控件数组元素不存在”
    ......
    第一次看到了希望。
      

  24.   

    用记事本把你的frm文件打开,把内容贴上来吧,不然不知你错在哪里.
      

  25.   

    Dim mnuTemp as Menu
    For Each mnuTemp In curChannels
        mnuTemp.Enabled=False
    Next mnuTemp
      

  26.   

    VERSION 5.00
    Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
    Begin VB.Form frmChannel 
       BorderStyle     =   1  'Fixed Single
       Caption         =   "通道选择"
       ClientHeight    =   4755
       ClientLeft      =   45
       ClientTop       =   615
       ClientWidth     =   11130
       FillStyle       =   0  'Solid
       LinkTopic       =   "Form1"
       MaxButton       =   0   'False
       MinButton       =   0   'False
       ScaleHeight     =   4755
       ScaleWidth      =   11130
       StartUpPosition =   2  '屏幕中心
       Begin VB.Data Data1 
          Caption         =   "Data1"
          Connect         =   "Access"
          DatabaseName    =   ""
          DefaultCursorType=   0  '缺省游标
          DefaultType     =   2  '使用 ODBC
          Exclusive       =   0   'False
          Height          =   345
          Left            =   5640
          Options         =   0
          ReadOnly        =   0   'False
          RecordsetType   =   1  'Dynaset
          RecordSource    =   ""
          Top             =   4440
          Visible         =   0   'False
          Width           =   1140
       End
       Begin MSDBGrid.DBGrid DBGrid1 
          Bindings        =   "frmChannel.frx":0000
          Height          =   4215
          Left            =   120
          OleObjectBlob   =   "frmChannel.frx":0014
          TabIndex        =   0
          Top             =   120
          Width           =   10935
       End
       Begin VB.Label Label2 
          Height          =   255
          Left            =   9240
          TabIndex        =   2
          Top             =   4440
          Width           =   1575
       End
       Begin VB.Label Label1 
          Height          =   255
          Left            =   240
          TabIndex        =   1
          Top             =   4440
          Width           =   4815
       End
       Begin VB.Menu files 
          Caption         =   "文件"
          Index           =   3000
          Begin VB.Menu SaveChannel 
             Caption         =   "通道状态保存"
             Enabled         =   0   'False
             Index           =   3001
          End
          Begin VB.Menu LoadChannel 
             Caption         =   "载入通道文件"
             Enabled         =   0   'False
             Index           =   3002
          End
          Begin VB.Menu TableRefresh 
             Caption         =   "刷新"
             Index           =   3003
             Shortcut        =   {F5}
          End
       End
       Begin VB.Menu Channel 
          Caption         =   "通道"
          Index           =   1000
          Begin VB.Menu AddChannel 
             Caption         =   "添加通道"
             Index           =   1001
             Shortcut        =   ^A
          End
          Begin VB.Menu DelChannel 
             Caption         =   "删除通道"
             Index           =   1002
             Shortcut        =   ^D
          End
          Begin VB.Menu EditChannel 
             Caption         =   "修改通道"
             Index           =   1003
             Shortcut        =   ^E
          End
          Begin VB.Menu menuline1 
             Caption         =   "-"
             Index           =   1006
          End
          Begin VB.Menu CurChannels 
             Caption         =   "当前状态"
             Enabled         =   0   'False
             Index           =   1004
             Shortcut        =   ^N
          End
          Begin VB.Menu MapChannels 
             Caption         =   "更换视图"
             Enabled         =   0   'False
             Index           =   1005
             Shortcut        =   ^V
          End
       End
       Begin VB.Menu ProgramSource 
          Caption         =   "节目源"
          Index           =   2000
          Begin VB.Menu AddSource 
             Caption         =   "添加节目源"
             Index           =   2001
          End
          Begin VB.Menu DelSource 
             Caption         =   "删除节目源"
             Index           =   2002
          End
          Begin VB.Menu EditSource 
             Caption         =   "修改节目源"
             Index           =   2003
          End
          Begin VB.Menu ShowSource 
             Caption         =   "显示节目源"
             Index           =   2004
          End
       End
       Begin VB.Menu ChannelOK 
          Caption         =   "设置完毕"
          Index           =   4000
       End
    End
    Attribute VB_Name = "frmChannel"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Private Sub AddChannel_Click(Index As Integer)Load frmAddChannelfrmAddChannel.Show
    End SubPrivate Sub Save_Click(Index As Integer)End SubPrivate Sub AddSource_Click(Index As Integer)If iChannel > 0 Then
        thisChannel = DBGrid1.Columns(0)    If DBGrid1.Columns(4) = "数据轮" Then
            Load frmAddSourceDataLun
            With frmAddSourceDataLun.Data1.Recordset
                .AddNew
                .Fields("通道号").Value = thisChannel
            End With
        
            frmAddSourceDataLun.Caption = "通道:" + Str(DBGrid1.Columns(0)) + " " + DBGrid1.Columns(3) + " " + DBGrid1.Columns(2) + " " + DBGrid1.Columns(4) + " " + DBGrid1.Columns(5) + " 至 " + DBGrid1.Columns(7)
            
            frmAddSourceDataLun.Show
        Else
            Load frmAddSourceMultiPro
            With frmAddSourceMultiPro.Data1.Recordset
                .AddNew
                .Fields("通道号").Value = thisChannel
            End With
            
            frmAddSourceMultiPro.Label5 = "通道:" + Str(thisChannel) + "    码率 :" + DBGrid1.Columns(1) + "    类型 :" + DBGrid1.Columns(4)
            
            frmAddSourceMultiPro.Show
        End If
    Else
        MsgBox "请先添加通道"
    End IfEnd SubPrivate Sub ChannelOK_Click(Index As Integer)
     
    If iChannel > 0 Then
        If iSource > 0 Then
            allOK = True
            MsgBox ("可以启动数据广播服务器了!")
            Unload Me
        Else
            MsgBox ("请添加节目源!")
        End If
    Else
        MsgBox ("请添加通道!")
    End IfEnd SubPrivate Sub Command1_Click()End SubPrivate Sub DBGrid1_DblClick()
    Call DisplaySource(DBGrid1)
    End SubPrivate Sub DelChannel_Click(Index As Integer)
    If iChannel > 0 Then
        Data1.Recordset.Delete
        iChannel = iChannel - 1
    Else
        MsgBox ("请添加通道!")
    End If
    End SubPrivate Sub DelSource_Click(Index As Integer)Dim rst As Recordset
    Dim strSource As String         '节目源类型
    Dim strItem As String           '节目源显示字段名称If iChannel > 0 Then
    thisChannel = DBGrid1.Columns(0)If DBGrid1.Columns(4) = "数据轮" Then
        strSource = "数据轮节目源"
        strItem = "节目源名称"
        iSourceType = 0
    Else
        strSource = "多协议节目源"
        strItem = "源地址"
        iSourceType = 1
    End IfSet rst = dbs.OpenRecordset("select * from " + strSource + " where 通道号=" + Str(iChannel))
    Load frmDelSourceWith rst
        While Not .EOF
            frmDelSource.List1.AddItem (rst.Fields(strItem).Value)
            .MoveNext
        Wend
    End With
    frmDelSource.Caption = Str(thisChannel) + " " + DBGrid1.Columns(2) + " " + DBGrid1.Columns(3) + " " + DBGrid1.Columns(4) + " " + DBGrid1.Columns(5)
    frmDelSource.Show
    Else
        MsgBox ("请添加通道!")
    End If
    End SubPrivate Sub EditChannel_Click(Index As Integer)
    Dim strSearch As StringIf iChannel > 0 Then
        thisChannel = DBGrid1.Columns(0)
        
        Load frmEditChannel
        
     
        strSearch = "通道号 =" + Str(thisChannel)
        With frmEditChannel.Data1.Recordset
            .MoveFirst
            .FindFirst strSearch
            If Not .NoMatch Then .Edit
        End With
        thisBitrate = Val(frmEditChannel.Text2)
        frmEditChannel.Show
    Else
        MsgBox ("没有通道!")
    End If
    End SubPrivate Sub EditSource_Click(Index As Integer)Dim rst As Recordset
    Dim path As String              '数据库路径
    Dim strSource As String         '节目源类型
    Dim strItem As String           '节目源显示字段名称
    Dim strList As String
    If iChannel > 0 Then
        thisChannel = DBGrid1.Columns(0)    If DBGrid1.Columns(4) = "数据轮" Then
            strSource = "数据轮节目源"
            strItem = "节目源名称"
            iSourceType = 0
            
        Else
            strSource = "多协议节目源"
            strItem = "源地址"
            iSourceType = 1
            
        End If    Set rst = dbs.OpenRecordset("select * from " + strSource + " where 通道号=" + Str(thisChannel))
        Load frmEditSourceWith rst
        While Not .EOF
            strList = "ID =" + Str(.Fields("ID").Value) + "    通道 = " + Str(rst.Fields("通道号")) + "  " + strItem + " = " + rst.Fields(strItem).Value
            frmEditSource.List1.AddItem (strList)
            .MoveNext
        Wend
    End With
    frmEditSource.Caption = Str(thisChannel) + " " + DBGrid1.Columns(2) + " " + DBGrid1.Columns(3) + " " + DBGrid1.Columns(4) + " " + DBGrid1.Columns(5)
    frmEditSource.ShowElse
        MsgBox ("请添加通道!")
    End IfEnd SubPrivate Sub Form_Load()
    Data1.DatabaseName = App.path + "\channel.mdb"
    Data1.RecordSource = "通道"
    Label2.Caption = "接口:" + Str(iInterface)End SubPrivate Sub ShowSource_Click(Index As Integer)
    Call DisplaySource(DBGrid1)
    End SubSub DisplaySource(dbgridx As DBGrid)Dim rst As Recordset
    Dim SQL As String
    thisChannel = dbgridx.Columns(0)Load frmShowSource
    If dbgridx.Columns(4) = "数据轮" Then
        SQL = "select * from 数据轮节目源 where 通道号=" + Str(thisChannel)
        Set rst = dbs.OpenRecordset(SQL)
        Set frmShowSource.Data1.Recordset = rst
        iSourceType = 0
    Else
        iSourceType = 1
        SQL = "select * from 多协议节目源 where 通道号=" + Str(thisChannel)
        Set frmShowSource.Data1.Recordset = dbs.OpenRecordset(SQL)
    End If
    frmShowSource.Caption = "通道:" + Str(dbgridx.Columns(0)) + " " + dbgridx.Columns(3) + " " + dbgridx.Columns(2) + " " + dbgridx.Columns(4) + " " + dbgridx.Columns(5) + "至" + dbgridx.Columns(7)
    frmShowSource.Top = Screen.Height * 0.4
    frmShowSource.Left = Screen.Width * 0.2
    frmShowSource.ShowEnd SubPrivate Sub TableRefresh_Click(Index As Integer)
    Data1.Refresh
    End Sub
      

  27.   

    Index中不要赋值嘛!这不是给自己找麻烦。若非要赋值,在原程序上用Me.files.Item(3000).Enabled = False试试,这我可是亲自试过的啊,不要添乱子了!