Enable属性改为false就行了
解决方案 »
- 如何在VB中快速截取数组中的一部分?
- 关于日期格式判断的问题!
- 请高手解释一下这段代码中的vbStr是怎么回事,我查了vb帮助,没有关于这个vbStr的说明
- TreeView树结构的问题,请教高手.解决后给100分.
- 简单的数据查询问题
- 求读取修改ini的源码。。。网上的看不懂
- 关于水晶报表的小问题
- 真正的专家上!
- vb中TreeView中key参数怎么用
- 小弟刚学VB不久,以下菜鸟问题请各位大侠指教:如何用VB实现COM DLL,请给出一个代码示例,万分感谢!!!1
- 我是菜鸟N号,急!请各位大虾!一个vb小问题。。。。。。。。。。。。。。。。。。。。。
- 请教高手,如何判断一个Com对象已经创建?
到哪去找这个对象?
你们自己设计过吗?
用的是Microsoft的Visual Basic 6.0吗?
不信你试试。
但是我需要在程序运行时设置。
private command_click()
mnufile.enable=false
end sub
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
你要Disable的菜单项的名称.Enabled=False
比如你填的名称是: MenuOK
那么就是
MenuOK.Enabled=False
打开文件-mnufile_open
private sub mnufile_open_click()
mnufile_open.enabled=false
End sub
名称:CurChannels
有效:未button1:
CurChannels.Enabled = True运行:
按下button1结果:
编译错误。
未找到方法或数据成员。
If TypeOf Control Is Menu Then
If ... then
Control.Enabled = True
Else
Control.Enabled = False
End If
End If
Next Control
或者用API函数GetMenu()获得主菜单,载GetSubMenu获得子菜单
me.CurChannels.Enabled =False
在输入me.时看看弹出的帮助框内是不是有CurChannels,若没有则说明你根本就没有CurChannels菜单,找到你自己需要的菜单名再来提问
但是curChannels后面没有enabled选项,只有
count
item
lbound
ubound
四个选项。
“不能在该控件中加enabled属性。”
重裝VB就好啦.(不怪它怪誰?)
count
item
lbound
ubound
四个选项适因为curChannels是菜单数组.
curChannels(0).Enabled=False
你说的很有道理。
我用curChannels(i).enabled 就可以赋值了。
但是无论我将i设为0或1或curChannels.count,都出错:
“控件数组元素不存在”
......
第一次看到了希望。
For Each mnuTemp In curChannels
mnuTemp.Enabled=False
Next mnuTemp
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