|
-
Jul 3rd, 2000, 10:42 AM
#1
Thread Starter
Lively Member
Now here's an easy yes/no question:
Can each item of a listbox (or combobox) have its own "Tag"? I'd like to display one thing but underlying it I'd like it to be something compeltely different. An example might be I'd like to show to the user a file name (e.g. "Autoexec.bat") but I'd like to store, associated with that item, the full path (e.g. "C:\Autoexec.bat").
Is that possible? How?
Thanks all,
Toot
Some cause happiness wherever they go; others, whenever they go.
-
Jul 3rd, 2000, 11:09 AM
#2
You can do somthing like this:
Code:
Option Explicit
Private m_MyArray(5) As String ' Size should match the number of entrys in the ListBox
Private Sub Form_Load()
List1.AddItem "Autoexec.bat"
m_MyArray(0) = "C:\Autoexec.bat"
List1.AddItem "MyFile.txt"
m_MyArray(1) = "C:\Program Files\Microsoft Office\Office\Examples\Solver\MyFile.txt"
End Sub
Private Sub List1_Click()
MsgBox m_MyArray(List1.ListIndex)
End Sub
-
Jul 3rd, 2000, 01:16 PM
#3
_______
/// ??? \\\
yes..also can be done using MS Databound ListBox or ComboBox
set your listfield to your display item (field1)
set your boundtext to your hidden item (field2)
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 3rd, 2000, 02:27 PM
#4
transcendental analytic
Yes, There is a property called ItemData to both listboxes and Combos, you can use it the same way as list
Code:
List1.AddItem "Autoexec.bat"
list1.itemdata(0) = "C:\Autoexec.bat"
List1.AddItem "MyFile.txt"
list1.itemdata(1) = "C:\Program Files\Microsoft Office\Office\Examples\Solver\MyFile.txt"
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 3rd, 2000, 03:16 PM
#5
kedaman: Itemdata must be numeric.
-
Jul 3rd, 2000, 04:19 PM
#6
transcendental analytic
I guess youre right Martin, i didn't think of that since i never used itemdata
anyway the listview control has a lot more features including tag's for each item
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 4th, 2000, 09:18 AM
#7
Thread Starter
Lively Member
OK folks thanks for your help. Looks like I'll be using the listview control a bit more then 
Toot
Some cause happiness wherever they go; others, whenever they go.
-
Jul 4th, 2000, 09:20 AM
#8
-
Jul 4th, 2000, 10:08 AM
#9
Lively Member
hmmm...Fox...i've notice you've increased a lot in your post count...is it because you helped a lot of people? Or because you've been posting a lot of useless messages like the one above?
-
Jul 4th, 2000, 10:23 AM
#10
-
Jul 4th, 2000, 03:36 PM
#11
transcendental analytic
Zej, What are you trying to accomplish? Don't yell on Fox, and definitely not on me or anybody else for posting freely
The only one caring about postcounts is you!
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|