Sign in to follow this  
Followers 0
PhilipG

Problem with listview items

5 posts in this topic

Iv encountered one more problem. I have a listview created by the following code:

$datelist = GUICtrlCreatelistview("Datum|från|till|Datumformat",171,90,143,187)
_GUICtrlListView_SetColumnWidth($datelist, 0, 59)
_GUICtrlListView_SetColumnWidth($datelist, 1, 40)
_GUICtrlListView_SetColumnWidth($datelist, 2, 40)
_GUICtrlListView_HideColumn($datelist, 3)

The list view items are den added by following function:

func add($mode, $date, $from, $too, $format)

if $mode = "add" then 
GUICtrlCreateListViewItem($date&"|"&$from&"|"&$too&"|"&$format, $datelist)
_GUICtrlListView_HideColumn($datelist, 3);döljer datumformat columnen
return
elseif $mode = "del" then
    GUICtrlDelete(GUICtrlRead($datelist))
    return
EndIf
EndFunc

The user could then save all items in to a database(sqlite)

this part works problem free!

But after that when the user wants to load saved data from the database. Thats when the weird stuff starts to happen

The update sequence is made by the following function:

func updatedate($i)
        _GUICtrlListView_DeleteAllItems($datelist)
        ;MsgBox(0,"", $i)
        $bQuery = "SELECT * FROM datum WHERE upd='"&$i&"' ORDER BY fran, datum;" ;Kollar vilken/vilka ul som är ansvariga
    Local $g, $iRows, $Col
    _SQLite_GetTable ($dbn, $bQuery, $g, $iRows, $Col);
    _ArrayDisplay($g)
$r=1
while $r <= $iRows
    $datum2=field($bQuery, "datumtext") + ($Col * $r)
    $from2=field($bQuery, "fran") + ($Col * $r)
    $too2=field($bQuery, "too") + ($Col * $r)
    $format2=field($bQuery, "datum") + ($Col * $r)
GUICtrlCreateListViewItem($g[$datum2]&"|"&$g[$from2]&"|"&$g[$too2]&"|"&$g[$format2], $datelist)
_GUICtrlListView_HideColumn($datelist, 3);döljer datumformat columnen
    $r=$r+1
    WEnd
EndFunc

field() is an other function to calculate witch element in the $g array that contains the info i need:

func field($q, $field);Kollar vilket nummer som resp fält har
        Local $i, $iRows, $Col
    _SQLite_GetTable ($dbn, $q, $i, $iRows, $Col); 
        $c = 1
        while $c <= $col
        if $i[$c] = $field Then
             
            return $c
        else 
            $c = $c+1
        EndIf
        WEnd
    EndFunc

The problem:

When the user loads info, one of the rows disappears. But sometimes it works just fine!

I have no clues what to do. I even tried to rewrite the script!

Any one with a sugestion?

Share this post


Link to post
Share on other sites



I've noticed one more thing:

when updatedate() is called for the first time it works, but when you try again it doesn't work at all, the top row keeps disappearing!

Share this post


Link to post
Share on other sites

Just found some other wierd thing...

After you load new info into the list view. If you then add one or more items to the list view. They also disappears if they are selected.

There is NO function, that I've written, called when you select an item.

Share this post


Link to post
Share on other sites

when you run just the updatedate() functionit works as well

The problem is when its executed from an other function.

I've tracked it, and as far as I can see it runs with out problem but then it deletes it anyway!

Share this post


Link to post
Share on other sites

I solved part of the problem. I moved the execution of the updatedate() function to the end of the calling function and now that parts works as well...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0