如何在 Visual Basic 6 中为每个列表项命名
我正在使用列表控件制作音乐播放器。我想让用户更改列表中歌曲的名称,但我希望 THAT 列表项的某些属性包含其路径。 请帮助我。任何形式的帮助将不胜感激。提前致谢。
编辑
Private Sub AddToList(ByVal txtFileName As String)
Dim I As Integer
Dim blnFileAlreadyexists As Boolean
txtFileName = Trim(txtFileName)
If txtFileName <> "" Then
blnFileAlreadyexists = False
For I = 0 To List1.ListCount - 1
If Trim(List1.List(I)) = txtFileName Then
blnFileAlreadyexists = True
End If
Next
If Not blnFileAlreadyexists Then
List1.AddItem (txtFileName)
List1.ItemData (txtFileName)
End If
End If
End Sub
I am making a music player using the list control. I want to let the user change the name of the song on the list, but i want some property of THAT list item to contain its path.
Please help me in this. Any kind of help will be appreciated. Thanks in advance.
EDIT
Private Sub AddToList(ByVal txtFileName As String)
Dim I As Integer
Dim blnFileAlreadyexists As Boolean
txtFileName = Trim(txtFileName)
If txtFileName <> "" Then
blnFileAlreadyexists = False
For I = 0 To List1.ListCount - 1
If Trim(List1.List(I)) = txtFileName Then
blnFileAlreadyexists = True
End If
Next
If Not blnFileAlreadyexists Then
List1.AddItem (txtFileName)
List1.ItemData (txtFileName)
End If
End If
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于列表框,添加项目后,将其
x.itemdata(x.newindex)
设置为包含相应数据的数组(或UDT数组)的索引。对于listview,您可以类似地使用单个项目
.Tag
或.Key
来存储数组(或集合)索引。链接列表框示例;
For a listbox, after you add an item set its
x.itemdata(x.newindex)
to the index of an array (or UDT array) that contains the corresponding data.For a listview you can similarly use an individual items
.Tag
or.Key
to store an array (or collection) index.Linking a listbox example;