Results 1 to 7 of 7

Thread: [RESOLVED]listbox tag and index property

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Location
    In A House :)
    Posts
    291

    Resolved [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

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    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!!

  3. #3
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718

    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)

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Location
    In A House :)
    Posts
    291

    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.

  5. #5
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718

    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)

  6. #6
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    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

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Location
    In A House :)
    Posts
    291

    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
  •  



Click Here to Expand Forum to Full Width