Valhalla Legends Forums Archive | Visual Basic Programming | ListItem and ListSubItem objects

AuthorMessageTime
LivedKrad
At the moment, I have code down where I am assigning a value to a ListItem object that I recently added to the listview.

[code]
Dim curItem As ListItem
Set curItem = Form1.ListView1.ListItems.Add(, , product)
[/code]

I did the same process to set a ListSubItem object to curItem's subitem.
[code]
Dim cursubItem As ListSubItem
Set cursubItem = Form1.ListView1.FindItem(curItem.Text, , curIndex).ListSubItems.Add(, , Username)
[/code]

The purpose of this was to provide access to previously unexposed properties of a ListView's SubItem item, and to make accessing to the already exposed ones a little easier. Now comes the problem..

I've tried and tried to set the cursubItem value  to point to an item's SubItem already in the ListView. I either am doing something wrong or I suck at life. I guess I'm going about it the wrong way, can anyone offer insight as to how to assign an item's SubItem already in the ListView to a ListSubItem object?
June 17, 2005, 6:22 PM
LivedKrad
The fact that I gained no reply (yes I'm impatient) prompted me to solve the problem on my own. With a little help from MSDN, I accomplished my task. For future references to this problem or another instance of this problem down the road, I wrote a small amount of code to demonstrate how objects reduce lengthy code.

[code]
Dim ptrList As listview
Dim curItem As ListItem
Dim ptrItem As ListItems
Dim ptrSubItem As ListSubItems
Dim curSubItem As ListSubItem
-----------------------------------------------------------------------------------
Private Sub Command1_Click()
ptrItem.Add , "Hello", "Hello World"

  Set curItem = ptrItem.Item("Hello")
  Set ptrSubItem = ptrList.ListItems(curItem.Index).ListSubItems

ptrSubItem.Add , "World", "Goodbye World"

  Set curSubItem = ptrSubItem.Item("World")

curSubItem.ForeColor = vbBlue 'We can now reference all properties of any item (specified by any unique key exemplified above)
curItem.Bold = True 'We can now reference all properties of any SUB item (specified by any unique key exemplified above)
End Sub
--------------------------------------------------------------------------------------------
Private Sub Form_Load()
Set ptrList = lv1
Set ptrItem = ptrList.ListItems
End Sub
[/code]
June 18, 2005, 3:01 AM
NicoQwertyu
Why on Earth would you "bump" a topic that is already the first thread on the forum?  :-\
June 18, 2005, 3:09 AM
LivedKrad
At the moment it was urgent for reasons that do not concern you, assuming that was even your business.

Edit: For additional reponses to your questions, see the statement inside the parentheses of post #2. Also, I removed the "bump" post so as to make you look like a fool when this post gets read at position-in-forum five or so and there is no "bump" in question! Owned! (</kidding>)
June 18, 2005, 5:22 AM
NicoQwertyu
[quote author=LivedKrad link=topic=11872.msg116330#msg116330 date=1119072131]
At the moment it was urgent for reasons that do not concern you, assuming that was even your business.

Edit: For additional reponses to your questions, see the statement inside the parentheses of post #2. Also, I removed the "bump" post so as to make you look like a fool when this post gets read at position-in-forum five or so and there is no "bump" in question! Owned! (</kidding>)
[/quote]
In that case, any of your future posts that I may be able to help you with "don't concern me," asshole.
June 18, 2005, 5:24 AM
LivedKrad
Not sure how I'm an asshole just because I said that the reason I bumped it was not of your concern. Care to elaborate, friend?

Edit: Although I am deeply saddened and dismayed by the fact that I shall never receive your help, I forsee *most* of my future questions being answered by someone who is equally as godly as you in the language of Visual Basic.
June 18, 2005, 5:25 AM
QwertyMonster
Off topic: You two are argueing over nothing. Its pretty much pointless.

Locking this topic or stopping might help.

On Topic: Nice job on solving it on your own and posting how you did it. Congrats.
June 18, 2005, 8:26 AM
LivedKrad
May help someone else in the future, so why not! As many bot sources as I've seen, people don't utilize objects properly, if at all. People seem more concerned about the non-objected oriented side of VB, the rapid development event-driven side. The reason I'm trying to get more objecto oriented is because I want to get to know the collections and types and objects a lot better; this way I can utilize VB to its full potential and even mimic some of the main OOPL aspects like encapsulation and inheritance.

VB has a lot more to offer than what most BNCS bot writers see. :(
June 18, 2005, 8:31 AM

Search