Listview Insert_Item Issue

Started by Anonymous, November 23, 2005, 05:34:30 PM

Previous topic - Next topic

Anonymous

Hi there!

Just purchased Firefly a couple days ago and I couldn't be happier.  It's released me from the drudgery of the user interface and allowed me to get back to programming (hurray!).

However...I'm having a problem with list_view...I've been mulling my way through a number of issues and eventually have gotten through them, but this one has me stumped.

I created a list_view with 16 columns.  I can get text to print in column 0, but I've been completely unsuccessful getting any text beyond that first column (except for the column headers, they work fine).  I even copied the first coulmn's text as part of my troubleshooting to make sure nothing has changed except the column number - it still won't do it.  Any ideas?!


If teamorleague = 1 Then
'team, thank you!  
row = 1  
For x = 1 To 25
FF_ListView_InsertItem (HWND_FRMSTATISTICS_LSTSTATISTICS, row, 0, Trim$(player(teams(toShow).roster(x)).lastname)+", "+Trim$(player(teams(toShow).roster(x)).firstname))      
FF_ListView_InsertItem (HWND_FRMSTATISTICS_LSTSTATISTICS, row, 1, Trim$(player(teams(toShow).roster(x)).lastname)+", "+Trim$(player(teams(toShow).roster(x)).firstname))
Incr row
Next x
Else
end if


Again, the ZERO column prints the info.  Column ONE is left blank.  What gives?

Here's my column creation piece (not sure if you need this)


FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 0, "Name", 0, 130  
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 1, "Pos", 0, 130
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 2, "G", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 3, "AVG", 2, 40  
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 4, "OBP", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 5, "AB", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 6, "R", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 7, "H", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 8, "2", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 9, "3", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 10, "HR", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 11, "RBI", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 12, "W", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 13, "K", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 14, "SB", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 15, "CS", 2, 40


What am I doing wrong?  Any and all help is appreciated!

Paul D. Elliott


rtc = FF_ListView_InsertItem(HWND_SEARCH_LVSEARCH, row, 0, "", 0, 0)
         
   wrk = Right$("        " & Str$(row + 1), 8)
   rtc = FF_ListView_SetItemText(HWND_SEARCH_LVSEARCH, row, 0, wrk)


I'm not sure that it's exactly correct but it works for me.
I do the InsertItem with a Null just to get things set up then
SetItemText with the data for the columns ( the number after "row" ).

Hope this helps.

Anonymous

Thanks for the help!  I tried it, but I still have nothing in column 1 - I'm really not sure what's going on here.  For hoots...here's a snapshot of the entire function:


Sub showStatistics (teamOrLeague As Byte, toShow As Byte, typeOfStats As Byte, Optional classToShow As Byte)
                                             
Local x As Integer
Local row As Integer    
Local rtc As Integer          
Local wrk As String

FF_ListView_DeleteAllItems (HWND_FRMSTATISTICS_LSTSTATISTICS)  
For x = 0 To 16
FF_ListView_DeleteColumn (HWND_FRMSTATISTICS_LSTSTATISTICS,0)
Next x
Select Case typeOfStats '1 = batting, 2= pitching, 3 = fielding

Case 1:                                  

FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 0, "Name", 0, 130  
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 1, "Pos", 0, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 2, "G", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 3, "AVG", 2, 40  
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 4, "OBP", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 5, "AB", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 6, "R", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 7, "H", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 8, "2", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 9, "3", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 10, "HR", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 11, "RBI", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 12, "W", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 13, "K", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 14, "SB", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 15, "CS", 2, 40
Case 2:  
       FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 0, "Name", 0, 130  
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 1, "W", 2, 40  
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 2, "L", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 3, "S", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 4, "ERA", 2, 50
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 5, "G", 2, 40
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 6, "GS", 2, 50
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 7, "IP", 2, 50
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 8, "H", 2, 50
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 9, "R", 2, 50
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 10, "ER", 2, 50
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 11, "W", 2, 50
FF_ListView_InsertColumn HWND_FRMSTATISTICS_LSTSTATISTICS, 12, "K", 2, 50
End Select                            

If teamorleague = 1 Then
'team, thank you!  
row = 1  
For x = 1 To 25
FF_ListView_InsertItem (HWND_FRMSTATISTICS_LSTSTATISTICS, row, 0, Trim$(player(teams(toShow).roster(x)).lastname)+", "+Trim$(player(teams(toShow).roster(x)).firstname))      
rtc = FF_ListView_InsertItem (HWND_FRMSTATISTICS_LSTSTATISTICS, row, 1, "",0,0)    
wrk = "hi"
rtc = FF_ListView_SetItemText(HWND_FRMSTATISTICS_LSTSTATISTICS, row, 1, wrk)
debug (player(teams(toShow).roster(x)).singlePotential)
Incr row
Next x
Else
   'league, thank you!
End If
                                                 
End Sub                                                                                        

Haakon Birkeland

Isn't the first row in a listview 0 based. You seem to start with row =1.

ReDim gRecord(0 To Count - 1) As RecordData
FF_ListView_DeleteAllItems HWND_JOBFORM_LISTVIEW1
For Ctr = 0 To Count - 1
TempStr                 = Parse$(JobRecords, $CrLf, Ctr + 1)  
gRecord(Ctr).tDate      = Parse$(TempStr,1)
FF_ListView_InsertItem HWND_JOBFORM_LISTVIEW1, Row, 0    , Trim$(gRecord(Ctr).tDate), 0, 0
gRecord(Ctr).tJobNum    = Parse$(TempStr,2)  
FF_ListView_InsertItem HWND_JOBFORM_LISTVIEW1, Row, 1, Trim$(gRecord(Ctr).tJobNum), 0, 0
gRecord(Ctr).tCustomer  = Parse$(TempStr,3)  
FF_ListView_InsertItem HWND_JOBFORM_LISTVIEW1, Row, 2, Trim$(gRecord(Ctr).tCustomer), 0, 0
gRecord(Ctr).tJobName   = Parse$(TempStr,4)  
FF_ListView_InsertItem HWND_JOBFORM_LISTVIEW1, Row, 3, Trim$(gRecord(Ctr).tJobName), 0, 0
gRecord(Ctr).tValue  = Parse$(TempStr,7)
FF_ListView_InsertItem HWND_JOBFORM_LISTVIEW1, Row, 4, Trim$(gRecord(Ctr).tValue), 0, 0
gRecord(Ctr).tBilled  = Parse$(TempStr,8)
FF_ListView_InsertItem HWND_JOBFORM_LISTVIEW1, Row, 5, Trim$(gRecord(Ctr).tBilled), 0, 0
gRecord(Ctr).tRemaining = Format$(Val(gRecord(Ctr).tValue) - Val(gRecord(Ctr).tBilled))
FF_ListView_InsertItem HWND_JOBFORM_LISTVIEW1, Row, 6, Trim$(gRecord(Ctr).tRemaining), 0, 0
gRecord(Ctr).tCompleted = Parse$(TempStr,5)  
FF_ListView_InsertItem HWND_JOBFORM_LISTVIEW1, Row, 7, Trim$(gRecord(Ctr).tCompleted), 0, 0  
'make the last record visible

'CustomerDB adds all the customers to an array used as a database for easier entering
CustomerDB Parse$(TempStr,3)                                      
Incr Row
Next Ctr


This code works for me so
Haakon 8o)

Anonymous

Yow know, this makes no sense to me, but when I start my rows at zero instead of 1 the dang thing works.

Thanks!  You're a Godsend!

Roger Garstang

Key thing to remember in inserting to listviews is not only zero based as mentioned, but when you insert a value, it may not always insert at the expected position as you specify...especially if it is sorted.  Always start out inserting to column 0 then using the return value from the function call inserting that value...use it as the row for the following column values in that row.  I like using -1 for the original row to insert too, then it will be at the end of the list if the control isn't sorted:

tmpVal= FF_ListView_InsertItem(HWND_Lview, -1, 0, column0Txt)
FF_ListView_InsertItem(HWND_Lview,, tmpVal, 1, column1Txt)
FF_ListView_InsertItem(HWND_Lview,, tmpVal, 2, column2Txt)
FF_ListView_InsertItem(HWND_Lview,, tmpVal, 3, column3Txt)