-
Aug 13th, 2024, 01:58 PM
#1
Thread Starter
Addicted Member
Need Light Weight List Control With .TAG for Each Line
Can use a ListView Report but do not want to ! Too much coding and maintenance.
Looking for a VB6 control like a ListBox that has a .Tag property for each list row.
Header not required.
Need both scrollbars available.
Anything available ?
-
Aug 13th, 2024, 02:04 PM
#2
Thread Starter
Addicted Member
Re: Need Light Weight List Control With .TAG for Each Line
Sorry "LightWeight" was not what I meant, as in Shape or Line etc.
To clarify in this instance I mean a control that does have the minimal features.
Like a ListBox.
.ListCount
.Selected )AKA Checkboex)
.List(Index)
.ItemData(Index) OPTIONAL
.Remove(Index)
-
Aug 14th, 2024, 01:19 AM
#3
Re: Need Light Weight List Control With .TAG for Each Line
Are the Values you want to store in that "per Item"-TAG-Property unique?
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Aug 14th, 2024, 01:50 AM
#4
Re: Need Light Weight List Control With .TAG for Each Line
Originally Posted by LorinM
Sorry "LightWeight" was not what I meant, as in Shape or Line etc.
To clarify in this instance I mean a control that does have the minimal features.
Like a ListBox.
.ListCount
.Selected )AKA Checkboex)
.List(Index)
.ItemData(Index) OPTIONAL
.Remove(Index)
There is no Tag property for each ListItem, so you have to maintain an additional array/collection to store these.
-
Aug 14th, 2024, 02:12 AM
#5
Re: Need Light Weight List Control With .TAG for Each Line
If you're not overly worried about reusing this, just use the ItemData property on the ListBox control to hold an index into another [hidden] ListBox that holds your "Tags".
Code:
List1.AddItem( "Fred" )
List2.AddItem( "Flintstone" )
List1.ItemData( List1.NewIndex ) = List2.NewIndex
Dim sTag as String : sTag = List2.List( List1.ItemData( List1.ListIndex ) )
' \________/ \____________/ \_____________/
' | | |
' | | Selected Item in List1
' | Index into 'Tags' list
' Extract tag
If you are likely to reuse this, wrap these two into a UserControl.
Regards, Phill W.
-
Aug 14th, 2024, 08:40 AM
#6
Re: Need Light Weight List Control With .TAG for Each Line
Yeah, my first thought was bite the bullet and use the ListView.
However, using a VB6 collection (which doesn't require another reference) that mirrors your ListBox would also be a trivial solution. You'd just have to figure out what to use for the key for your collection. Maybe I'll work out some simple procedures to do this and post them. Sounds like a fun little project.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Aug 14th, 2024, 09:11 AM
#7
Re: Need Light Weight List Control With .TAG for Each Line
Hmmm, it turns out that there's just nothing that I can see to uniquely identify the items in a ListBox, not even with API calls. So, to handle duplicates, it'd take some sophisticated tracking of the index values (which are subject to change).
I suppose another option is to set a tab in the ListBox that's off the right side, and then put some hidden text out there to be used as your Tag.
However, rather than do all of that, the ListView is just trivially does it, so that's truly the way to go.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Aug 14th, 2024, 10:57 AM
#8
Thread Starter
Addicted Member
Re: Need Light Weight List Control With .TAG for Each Line
Has not someone connected a ListBox and Collection to make a, what I would call, a proper listbox.
MS should of made ItemData a variant, Oh well.
-
Aug 14th, 2024, 11:29 AM
#9
Re: Need Light Weight List Control With .TAG for Each Line
You may look at makeing your own custom listbox I did one years back by rendering the items onto a picturebox and scrollbars were need. I found this maybe not what your looking for but may give you can idea
https://www.vbforums.com/showthread....n-32-767-Items
also this may give you some ideas good luck
https://www.vbforums.com/showthread....andard-ListBox
-
Aug 14th, 2024, 02:09 PM
#10
Re: Need Light Weight List Control With .TAG for Each Line
Originally Posted by LorinM
Has not someone connected a ListBox and Collection to make a, what I would call, a proper listbox.
MS should of made ItemData a variant, Oh well.
Use the itemdata as index to an array of an UDT, then you can store anything you need in it
-
Aug 15th, 2024, 01:43 PM
#11
Thread Starter
Addicted Member
Re: Need Light Weight List Control With .TAG for Each Line
Using a UDT get messy when Removing a list item.
-
Aug 15th, 2024, 06:31 PM
#12
Re: Need Light Weight List Control With .TAG for Each Line
you can wrap a list view in a user control and minimize the work required to manage it
building your own list control with just what you want will probably be more work. i've have basically completely given up on list boxes at this point. i always want a list view with filtering capabilities and simplified api now. the extra wrappers like copy column or copy all or simplified adding sub elements is nice to have by default
https://www.vbforums.com/showthread....rol&highlight=
Last edited by dz32; Aug 15th, 2024 at 06:34 PM.
-
Aug 16th, 2024, 01:46 AM
#13
Re: Need Light Weight List Control With .TAG for Each Line
Originally Posted by LorinM
Using a UDT get messy when Removing a list item.
What is the purpose of the listbox?
Most often it's used for displaying a static list to users
-
Aug 16th, 2024, 02:17 PM
#14
Thread Starter
Addicted Member
Re: Need Light Weight List Control With .TAG for Each Line
Yes, but I need an ItemData that will hold at least String?
I have written one now, MyListBoxEnhanced, that I am converting to a usercontrol.
Wish me luck since my skills are diminishing with age.
-
Aug 17th, 2024, 01:27 PM
#15
Re: Need Light Weight List Control With .TAG for Each Line
Good look with your listbox. you can also look at one I made to for idea a bit old now and may need updating a bit.
https://github.com/Planet-Source-Cod...stbox__1-65554
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
|