|
-
Jun 2nd, 2006, 07:39 AM
#1
Thread Starter
Fanatic Member
[Resolved] ListView Strange Problem =S
I have another problem.
I'm using the list view to show data from a file.
It splits it up into columns and cell etc etc
A Strange thing happens when i clear the listview and then reload the data into it (a refresh options). It's for a game by the way.
The following happens.. say this is my table here
("" is the next cell, i didn't want to post a pic too long)
Snail "" 5/0 "" 4 "" 6 "" 00001
Slime "" 6/7 "" 3 "" 7 "" 00002
Something Else "" 1/2 "" 6 "" 7 "" 0003
I use the same code to reload the listview from the file, i just use the ListView.Clear function before reloading the data.
Slime "" "" "" ""
Something Else "" "" "" ""
Snail "" 1/2 "" 6 "" 7 "" 0003
They load in what looks like reverse, but only the bottom stats for the monster shows up and its not even for the monster (the names rearrange).
If you want a screen shot, i can provide it
Here's the code:
VB Code:
Private Sub Form_Load()
LstMonster.ListItems.Clear
Load_Monsters LstMonster
End Sub
'The Loading sub
Public Sub Load_Monsters(List_ As ListView)
List_.ListItems.Clear
DoEvents
Dim Monsters_() As String
Dim MStats_() As String
Dim SText As String
Dim I As Integer
SText = ""
I = 0
Open "MonsterList.txt" For Input As #1
SText = Input(LOF(1), #1)
Close #1
Monsters_ = Split(SText, "|MSplit|")
List_.SortKey = Left(Monsters_(0), 2)
For I = 1 To UBound(Monsters_)
Mstats = Split(Monsters_(I), "|LSplit|")
List_.ListItems.Add , , Mstats(0)
List_.ListItems.Item(I).SubItems(1) = Trim(Mstats(1))
List_.ListItems.Item(I).SubItems(2) = Trim(Mstats(2))
List_.ListItems.Item(I).SubItems(3) = Trim(Mstats(3))
List_.ListItems.Item(I).SubItems(4) = Trim(Mstats(4))
List_.ListItems.Item(I).SubItems(5) = Trim(Left(Mstats(5), 5))
Next I
List_.Sorted = True
End Sub
'Here's the refresh code that i use (just reload because the clear is in the load code)
Private Sub Refresh_Click()
Load_Monsters LstMonster
end sub
Last edited by Hack; Jun 2nd, 2006 at 08:33 AM.
Reason: Added green "resolved" checkmark Last edited by Slyke : Today at 09:31 AM.
-
Jun 2nd, 2006, 07:53 AM
#2
Re: ListView Strange Problem =S
Can you attach the file "MonsterList.txt" ?? so we can "play" with it?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 2nd, 2006, 08:16 AM
#3
Thread Starter
Fanatic Member
Re: ListView Strange Problem =S
-
Jun 2nd, 2006, 08:23 AM
#4
Re: ListView Strange Problem =S
ok do it like this (Using a ListItem Object)
VB Code:
Public Sub Load_Monsters(List_ As ListView)
List_.ListItems.Clear
DoEvents
Dim Monsters_() As String
Dim MStats_() As String
Dim SText As String
[B]Dim LI As ListItem[/B]
Dim I As Integer
SText = ""
I = 0
Open "C:\MonsterList.txt" For Input As #1
SText = Input(LOF(1), #1)
Close #1
Monsters_ = Split(SText, "|MSplit|")
List_.SortKey = Left(Monsters_(0), 2)
For I = 1 To UBound(Monsters_)
Mstats = Split(Monsters_(I), "|LSplit|")
[B]Set LI = List_.ListItems.Add(, , Mstats(0))[/B]
[B]LI.SubItems(1) = Trim(Mstats(1))
LI.SubItems(2) = Trim(Mstats(2))
LI.SubItems(3) = Trim(Mstats(3))
LI.SubItems(4) = Trim(Mstats(4))
LI.SubItems(5) = Trim(Left(Mstats(5), 5))[/B]
Next I
List_.Sorted = True
End Sub
your code didnt seem to add the subitems to the right things? odd.. but this worked
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 2nd, 2006, 08:31 AM
#5
Thread Starter
Fanatic Member
Re: ListView Strange Problem =S
Thanks! It works great now.
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
|