你好,我想在VB 中建立一个下拉菜单,用combobox控件
4个回答
展开全部
Private Sub Combo1_Click()
Select Case Combo1.Text
Case "红"
Me.BackColor = RGB(255, 0, 0)
Case "黄"
Me.BackColor = RGB(255, 255, 0)
Case "绿"
Me.BackColor = RGB(0, 255, 0)
Case "青"
Me.BackColor = RGB(0, 255, 255)
Case "蓝"
Me.BackColor = RGB(0, 0, 255)
Case "紫"
Me.BackColor = RGB(255, 0, 255)
Case "黑"
Me.BackColor = RGB(0, 0, 0)
Case "白"
Me.BackColor = RGB(255, 255, 255)
Case Else
Me.BackColor = Me.BackColor
End Select
End Sub
Private Sub Form_Load()
Combo1.AddItem "红"
Combo1.AddItem "黄"
Combo1.AddItem "绿"
Combo1.AddItem "青"
Combo1.AddItem "蓝"
Combo1.AddItem "紫"
Combo1.AddItem "黑"
Combo1.AddItem "白"
End Sub
Select Case Combo1.Text
Case "红"
Me.BackColor = RGB(255, 0, 0)
Case "黄"
Me.BackColor = RGB(255, 255, 0)
Case "绿"
Me.BackColor = RGB(0, 255, 0)
Case "青"
Me.BackColor = RGB(0, 255, 255)
Case "蓝"
Me.BackColor = RGB(0, 0, 255)
Case "紫"
Me.BackColor = RGB(255, 0, 255)
Case "黑"
Me.BackColor = RGB(0, 0, 0)
Case "白"
Me.BackColor = RGB(255, 255, 255)
Case Else
Me.BackColor = Me.BackColor
End Select
End Sub
Private Sub Form_Load()
Combo1.AddItem "红"
Combo1.AddItem "黄"
Combo1.AddItem "绿"
Combo1.AddItem "青"
Combo1.AddItem "蓝"
Combo1.AddItem "紫"
Combo1.AddItem "黑"
Combo1.AddItem "白"
End Sub
展开全部
VB本来就菜单,而且就是下拉式的,还可以建弹出式菜单,何必用COMBOBOX
改变背景颜色,只需改变窗体的 即可BackColor,如
.ME. me.BackColor = RGB(255,0,0)'红色
ME. me.BackColor = RGB(255,255,0)'黄色
ME. me.BackColor = RGB(0,255,0)'绿色
ME. me.BackColor = RGB(0,255,255)'青色
ME. me.BackColor = RGB0,0,255)'蓝色
ME. me.BackColor = RGB(255,0,255)'紫色
ME. me.BackColor = RGB(0,0,0)'黑色
ME. me.BackColor = RGB(255,255,255)'白色
改变背景颜色,只需改变窗体的 即可BackColor,如
.ME. me.BackColor = RGB(255,0,0)'红色
ME. me.BackColor = RGB(255,255,0)'黄色
ME. me.BackColor = RGB(0,255,0)'绿色
ME. me.BackColor = RGB(0,255,255)'青色
ME. me.BackColor = RGB0,0,255)'蓝色
ME. me.BackColor = RGB(255,0,255)'紫色
ME. me.BackColor = RGB(0,0,0)'黑色
ME. me.BackColor = RGB(255,255,255)'白色
追问
额,是要建立一个有换肤功能的界面,选择颜色名称就能改变背景颜色,用按钮的话不好看不是
追答
在VB的菜单样里,选择"工具"-----"菜单编辑器",用它可以创建组下拉式菜单,你可以创建一个"窗体背景"的菜单,然后在它下面创建一组子菜单,不但可以改变背景颜色,还可以加载背景图片,也就是你说的换肤功能.你可以看看,试一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Combo1_Click()
Me.BackColor = Choose(Combo1.ListIndex + 1, vbRed, vbGreen, vbBlue, vbYellow, vbWhite, vbBlack)
End Sub
Private Sub Form_Load()
Combo1.AddItem "红"
Combo1.AddItem "绿"
Combo1.AddItem "蓝"
Combo1.AddItem "黄"
Combo1.AddItem "白"
Combo1.AddItem "黑"
Combo1.ListIndex = 0
End Sub
Me.BackColor = Choose(Combo1.ListIndex + 1, vbRed, vbGreen, vbBlue, vbYellow, vbWhite, vbBlack)
End Sub
Private Sub Form_Load()
Combo1.AddItem "红"
Combo1.AddItem "绿"
Combo1.AddItem "蓝"
Combo1.AddItem "黄"
Combo1.AddItem "白"
Combo1.AddItem "黑"
Combo1.ListIndex = 0
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private sub form_load()
with combox
.clear
.additem "红"
.additem "绿"
.additem "蓝"
.listindex =0
end with
end sub
private sub combox_Click()
if combox.listindex =0 then
me.BackColor=vbRed
elseif combox.listindex =1 then
me.BackColor=vbGreen
elseif combox.listindex =2 then
me.BackColor=vbBlue
end if
end sub
with combox
.clear
.additem "红"
.additem "绿"
.additem "蓝"
.listindex =0
end with
end sub
private sub combox_Click()
if combox.listindex =0 then
me.BackColor=vbRed
elseif combox.listindex =1 then
me.BackColor=vbGreen
elseif combox.listindex =2 then
me.BackColor=vbBlue
end if
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询