📄 4076.html
字号:
<html>
<head>
<title>listbox同步</title>
</head>
<body bgcolor="#FFFFFF" vlink="#808080">
<center>
<h1>listbox同步</h1>
</center>
<hr size=7 width=75%>
<hr size=7 width=75%><p>
Posted by <a href="mailto:thomasaria@yahoo.com">Thomasaria</a> on July 21, 1998 at 11:28:49:<p>
(sorry占用本版,刚mail给该网页作者但被退回,所以公布于此看看大家有否意见)<p>在VB心得笔记网页(http://sunh.hosp.ncku.edu.tw/~cww/)中有篇「使两个ListBox项目同步」(http://sunh.hosp.ncku.edu.tw/~cww/htm28.htm),写的指令多了些,<p>Option Explicit<p> Sub Form_Load()<br> 'Initialize two list boxes with the alphabet<br> Dim i As Long<br> For i = 1 To 26<br> List1.AddItem Chr$(i + 64)<br> Next i<br> For i = 1 To 26<br> List2.AddItem Chr$(i + 64)<br> Next i<br> Timer1.Interval = 1<br> Timer1.Enabled = True<br> End Sub<p> Sub Timer1_Timer()<br> Dim TopIndex_List1 As Long<br> Static PrevTI_List1<br> 'Get the index for the first item in the visible list<br> TopIndex_List1 = List1.TopIndex<br> 'See if the top index has changed<br> If TopIndex_List1 <> PrevTI_List1 Then<br> 'Set the top index of List2 equal to List1 so that the list boxes<br> 'scroll to the same relative position<br> List2.TopIndex = TopIndex_List1<br> 'Keep track of the current top index<br> PrevTI_List1 = TopIndex_List1<br> End If<br> 'Select the item in the same relative position in both list boxes<br> If List1.ListIndex <> List2.ListIndex Then<br> List2.ListIndex = List1.ListIndex<br> End If<br> End Sub<p>可是实际上我简单用如下即可在拉卷轴时使两个ListBox项目同步<p>Private Sub List1_Scroll(Index As Integer)<br>'按卷动轴时list项目位置同步<br>List2.TopIndex = List1.TopIndex<br>End Sub<p>Private Sub List2_Scroll(Index As Integer)<br>'按卷动轴时list项目位置同步<br>List1.TopIndex = List2.TopIndex<br>End Sub<p>用计时器有何特殊理由吗?<p>Thomasaria<p>
<br>
<br><hr size=7 width=75%><p>
<a name="followups">Follow Ups:</a><br>
<ul><!--insert: 4076-->
<!--top: 4104--><li><a href="4104.html">你的做法是对的!</a> <b>小吴</b> <i>07:52:23 7/22/98</i>
(<!--responses: 4104-->3)
<ul><!--insert: 4104-->
<!--top: 4150--><li><a href="4150.html">Re: 你的做法是对的!</a> <b>cww</b> <i>15:25:44 7/23/98</i>
(<!--responses: 4150-->0)
<ul><!--insert: 4150-->
</ul><!--end: 4150-->
<!--top: 4134--><li><a href="4134.html">To:CWW</a> <b>Albert</b> <i>09:45:03 7/23/98</i>
(<!--responses: 4134-->1)
<ul><!--insert: 4134-->
<!--top: 4152--><li><a href="4152.html">您是对的</a> <b>cww</b> <i>15:43:38 7/23/98</i>
(<!--responses: 4152-->0)
<ul><!--insert: 4152-->
</ul><!--end: 4152-->
</ul><!--end: 4134-->
</ul><!--end: 4104-->
</ul><!--end: 4076-->
<br><hr size=7 width=75%><p>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -