|
-
Jul 13th, 2005, 03:39 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED]listbox tag and index property
is it possible to set the tag and index property in a listbox?
if not, how do i read all listbox members one at a time and get their tag property that was set...
sorry if it seems stupid, but 2 hours of searching the net and 6 books later i still don't have an answer.
i'm beginning to like cobol again.
Last edited by DirtyHowi; Jul 14th, 2005 at 03:24 PM.
Reason: RESOLVED
-
Jul 13th, 2005, 05:01 PM
#2
Re: listbox tag and index property
hmm dont have VB so just typing
For i as integer = 0 to myListBox.Items.Count -1
myListBox.Items(i).Tag = '...
Next
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jul 13th, 2005, 10:18 PM
#3
Re: listbox tag and index property
Nah, the listbox only has the Tag() property on the control, not on the individual items. To do the equivalent, simply include the ToString() function in your class and in that function, have it return the value you wish to have displayed.
Then simply add it to the ListBox. The control will then accept the class (because it accepts any object derived from Object) and then uses the ToString() method to determine what to display. When you use properties like SelectedItem(), it will return your class that you put in, simply convert it using the CType() function and you can use it.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
-
Jul 14th, 2005, 07:11 AM
#4
Thread Starter
Hyperactive Member
Re: listbox tag and index property
so what your telling me is i can't store the tag (what i need) from a listbox list of items?
what happens is a user chooses something from a list view, the tag and data get written to the list box, as a visual que of what will be written to the db...i want to roll through the box when the user clicks the apply button and write the tags to the table, otherwise i am duplicating data a major no no.
i can message box out the tag (ie it shows the correct tag for each item) in the selecteditemschanged event so i know the tag is following the item over.
i tried using two listviews but couldn't get the second one to display the items.
-
Jul 14th, 2005, 07:57 AM
#5
Re: listbox tag and index property
Can you rephrase that, I didn't quite understand that sorry.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
-
Jul 14th, 2005, 12:18 PM
#6
Re: listbox tag and index property
Hi,
It's slightly mysterious, given that a lot of the properties of objects have been aligned in the transition from VB6 to .Net, but the ListViewItem class uses the .Tag property to store stuff whereas the ListItem uses the .Value property.
You just refer to each of these as said so politely by Mr Polite, although in the form above.
Is that of help?
zaza
-
Jul 14th, 2005, 03:25 PM
#7
Thread Starter
Hyperactive Member
Re: [RESOLVED]listbox tag and index property
I resolved the dual listview issue, i hadn't created a column to put the data into so it wasn't showing up...
all fixed...now for the numeric up down,.
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
|