中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > Visual Basic > 综合文章
Visual Basic下工具条的制作之六
作者:未知 时间:2004-02-14 12:12 出处:eNet硅谷动力 责编:chinaitpower
              摘要:Visual Basic下工具条的制作之六
----下面的例子中,窗口工具条内有两个分别代表打开文件和文件存盘的按钮,另外还有一个设置窗口客户区颜色的组合框。为免去烦琐地介绍工具条的设置过程,在窗体制作时仅仅加入一个toolbar控件和一个imagelist控件,另外在toolbar中加入一个组合框combobox。其它所有与toolbar的设置和控制有关的操作都在程序代码中实现,包括为imagelist1加入图片库、建立toolbar1和imagelist1的关联关系、在toolbar1中加入按钮并为每个按钮设置属性、对combo1进行初始化等等。
  下面给出窗体form1的程序代码。 private sub form_load()

’ create object variable for the imagelist.

dim imgx as listimage

’ load pictures into the imagelist control.

set imgx = imagelist1.listimages. _

add(, "open", loadpicture("graphics\bitmaps\tlbr_w95\open.bmp"))

set imgx = imagelist1.listimages. _

add(, "save", loadpicture("graphics\bitmaps\tlbr_w95\save.bmp"))

toolbar1.imagelist = imagelist1

’ create object variable for the toolbar.

dim btnx as button

’ add button objects to buttons collection using the

’ add method. after creating each button, set both

’ description and tooltiptext properties.

toolbar1.buttons.add , , , tbrseparator

set btnx = toolbar1.buttons.add(, "open", , tbrdefault, "open")

btnx.tooltiptext = "open file"

btnx.description = btnx.tooltiptext

set btnx = toolbar1.buttons.add(, "save", , tbrdefault, "save")

btnx.tooltiptext = "save file"

btnx.description = btnx.tooltiptext

set btnx = toolbar1.buttons.add(, , , tbrseparator)

’ the next button has the placeholder style. a

’ combobox control will be placed on top of this button.

set btnx = toolbar1.buttons.add(, "combo1", , tbrplaceholder)

btnx.width = 1500 ’ placeholder width to accommodate a combobox.

show ’ show form to continue configuring combobox.

’ configure combobox control to be at same location as the

’ button object with the placeholder style (key = "combo1").

with combo1

.width = toolbar1.buttons("combo1").width

.top = toolbar1.buttons("combo1").top

.left = toolbar1.buttons("combo1").left

.additem "black" ’ add colors for text.

.additem "blue"

.additem "red"

.listindex = 0

end with

end sub

private sub form_resize()

’ configure combobox control.

with combo1

.width = toolbar1.buttons("combo1").width

.top = toolbar1.buttons("combo1").top

.left = toolbar1.buttons("combo1").left

end with

end sub

private sub toolbar1_buttonclick(byval button as button)

’ use the key property with the selectcase statement to specify

’ an action.

select case button.key

case is = "open" ’ open file.

msgbox "add code to open file here!"

case is = "save" ’ save file.

msgbox "add code to save file here!"

end select

end sub

private sub combo1_click()

’ change backcolor of form using the combobox.

select case combo1.listindex

case 0

form1.backcolor = vbblack

case 1

form1.backcolor = vbblue

case 2

form1.backcolor = vbred

end select

end sub
关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有