📄 010701.htm
字号:
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>vb study</title>
<style>
<!--
td {font-size: 9pt}
A:link {text-decoration: none; color: #0033cc;font-size: 9pt}
A:visited {text-decoration: none; color: #0066CC;font-size: 9pt}
A:active {text-decoration: none; color: #ff0000; font-size: 9pt}
A:hover {text-decoration: underline; color: #000000;font-size: 9pt}
-->
</style>
</head>
<body>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="98%">
<tr>
<td width="100%"><a href="#">你的位置</a>:<a href="http://www.xxby.com" target="_blank">华生小屋</a>--<a href="#">VB学习</a>--<a href="#">基本控件</a></td>
</tr>
<tr>
<td width="100%">
<p align="center">组合框Combo、ImageCombo对象</td>
</tr>
<tr>
<td width="100%"><br>
组合框combo对象与list大同小异,它可直接在那条文本框中输入所要的项文字,并可通过其change事件立即触发(只要你输入正确),你也可象list那样去选,此时也编写click事件,与list一模一样。<br>
★ 组合框combo对象有一个属性Style与列表框不同:为0时,有文本输入和可下拉列表;为1时,有文本输入和一个不能缩回的列表(简单组合框);为2时,无文本输入,只有下拉式列表。<br>
图片组合框imagecombo对象:它的功能仍是组合框,不过可在列表项中嵌入图形,要与imagelist对象联合。注意:它管理列表项的方式是:每一个列表项是一个单独的comboitem对象,整个列表是一个comboitems集合。 <br>
首先要将它与imagelist对象关联,在imagecombo对象的属性页"通用""图象列表"框中选择一个imagelist对象,或在代码中将其imagelist属性设为1个imagelist对象:<br>
Set imagecombo对象.imagelist=imagelist对象<br>
set imagecombo1.imagelist=imagelist1<br>
向组合框添加列表项(含图片),用comboitems集合的add方法:<br>
imagecombo对象.comboitems.add 新列表项索引,关健字,标题,图片,?,缩进<br>
其中索引值最小从1开始,图片为imagelist对象中图片索引值或关健字,如:<br>
ImageCombo1.ComboItems.Add 1, "lxm", "李小敏", "face1"<br>
在列表框中的列表项可有不同层次的缩进,由各列表项的indentation属性值决定,值加1表示缩进10个象素,应对单个的comboitem对象分别设置,如:<br>
ImageCombo1.ComboItems("lxm").Indentation = 4<br>
关健字为lxm的那个列表项将缩进40个象素的位置。<br>
运行时当在imagecombo中选中1个列表项时,就会体现在imagecombo对象的SelectedItem属性以及Text、SelText属性中,ImageCombo1. SelectedItem属性是当前选中的列表项对象,例如用ImageCombo1.SelectedItem.Key返回选中列表项对象的关健字,而SelectedItem.index返回选中列表项对象的索引值,等等。可用它来在代码中响应不同的选择:<br>
Private Sub Imagecombo1.Click()<br>
Select Case ImageCombo1.SelectedItem.Text (或Select Case ImageCombo1.Text)<br>
Case "小王"<br>
End<br>
Case "小刘"<br>
Beep<br>
Case "小齐"<br>
Form1.WindowState = 2<br>
End Select<br>
End Sub<br>
注:控件的Text、SelText、SelectedItem属性是有区别的,SelectedItem属性是选中的列表项"对象",其中包含了该对象的所有属性,如Index,Key,Text,Image等等。要用此属性。而Text是指ImageCombo对象的那个文本框内的文字,而SelText是文本框内用蓝色背景标明选中的字串(如果将蓝色背景去掉,用seltext就不起作用了,如设sellength属性=0)。<br>
还有1种办法,运行时当选中某个列表项对象时,该"列表项对象"的selected属性就为true,因此可以标识当前选中的不同列表项对象而进行不同响应,如:<br>
If ImageCombo1.ComboItems(1).Selected = True Then End<br>
If ImageCombo1.ComboItems(2).Selected = True Then Beep
<p align="center">
<br>
< <a href="010601.htm">上一页</a>--<a href="http://www.xxby.com" target="_blank">华生小屋</a>--<a href="010801.htm">下一页</a>
><br>
</p>
</td>
</tr>
</table>
</center>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -