Jump to content

Problem with listview items


PhilipG
 Share

Recommended Posts

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?

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...