Jump to content

Highlight item that is moved down/up in ListView?


gobsor
 Share

Recommended Posts

Heyah... once more a problem with ListView!

That's how I'm filling the ListView after browsing a dir, notice that I'm using _GUICtrlListView_SetItemSelected($hSourceView, 0, True, True).

Works perfect, ListView is being filled and 1st item is Focused/Highlighted (in common blue 'this row is highlighted' color).

Func _fillSourceView($path)
    _clearListView($hSourceView)
    $files = _FileListToArray($path, "*.mp3")
    For $i = 1 To UBound($files)-1
        $size = FileGetSize($path&$files[$i])
        _GUICtrlListView_BeginUpdate($hSourceView)
        GUICtrlCreateListViewItem(_properNum($i) & "|" & $files[$i] & "|" & _properSize($size), $hSourceView)
        If Mod($i, 2) = 0 Then 
            GUICtrlSetBkColor(-1, 0xE9F2F5) 
        EndIf
    Next
    _GUICtrlListView_SetItemSelected($hSourceView, 0, True, True)
    $iIndex = 0
    _GUICtrlListView_EndUpdate($hSourceView)
    _GUICtrlButton_Enable($idReload, True)
EndFunc ;==> _fillSourceView($path)

Okay, now I got two buttons to move subitems down/up in ListView, that's how I'm doing it:

Func _clickMoveUp()
    _GUICtrlListView_BeginUpdate($hSourceView)
    _switchItemText($hSourceView, $iIndex, $iIndex-1, 1)
    _switchItemText($hSourceView, $iIndex, $iIndex-1, 2)
    _GUICtrlListView_SetItemSelected($hSourceView, $iIndex-1, True, True)
    _GUICtrlListView_EndUpdate($hSourceView)
    $iIndex = $iIndex - 1
EndFunc ;==> _clickMoveUp()

Func _clickMoveDn()
    _GUICtrlListView_BeginUpdate($hSourceView)
    _switchItemText($hSourceView, $iIndex, $iIndex+1, 1)
    _switchItemText($hSourceView, $iIndex, $iIndex+1, 2)
    _GUICtrlListView_SetItemSelected($hSourceView, $iIndex+1, True, True)
    _GUICtrlListView_EndUpdate($hSourceView)
    $iIndex = $iIndex + 1
EndFunc ;==> _clickMoveDn()

Func _switchItemText($hWnd, $iIndex_1, $iIndex_2, $iSubItem)
    Local $temp = _GUICtrlListView_GetItemText($hWnd, $iIndex_1, $iSubItem)
    _GUICtrlListView_BeginUpdate($hWnd)
    _GUICtrlListView_SetItemText($hWnd, $iIndex_1, _GUICtrlListView_GetItemText($hWnd, $iIndex_2, $iSubItem), $iSubItem)
    _GUICtrlListView_SetItemText($hWnd, $iIndex_2, $temp, $iSubItem)
    _GUICtrlListView_EndUpdate($hWnd)
EndFunc

Works fine so far aswell, subitem is being moved up/down, depending on the button pressed, but why doesn't the moved item get highlighted

after it got moved?

Shouldn't

_GUICtrlListView_SetItemSelected($hSourceView, $iIndex+1, True, True)
_GUICtrlListView_SetItemSelected($hSourceView, $iIndex-1, True, True)

move the 'highlight' down/up in ListView, depending on the button pressed? SubItem's are exchanged and I can move the selected one to either

the button or the top of the list, but somehow it's not highlighted and hard to see which one is moved right now.

Thanks in advance!

Link to comment
Share on other sites

  • 2 weeks later...

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...