Jump to content

ListView subitems edit in place (by double click)


rasim
 Share

Recommended Posts

Hi! This simple example showed, how to edit in place a ListView subitems.

Posted Image

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>

Opt("GuiCloseOnESC", 0)

Global $hEdit, $Item = -1, $SubItem = 0

Global $Style = BitOR($WS_CHILD, $WS_VISIBLE, $WS_BORDER, $ES_AUTOHSCROLL, $ES_LEFT)

$hGUI = GUICreate("ListView Subitems edit in place", 300, 200)

$hListView = _GUICtrlListView_Create($hGUI, "Items|SubItems", 2, 2, 296, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_GRIDLINES)

For $i = 1 To 10
    _GUICtrlListView_AddItem($hListView, "Item " & $i)
    _GUICtrlListView_AddSubItem($hListView, $i - 1, "SubItem " & $i, 1)
Next

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tNMHDR, $hWndFrom, $iCode

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    
    Switch $hWndFrom
        Case $hListView
            Switch $iCode
                Case $NM_DBLCLK
                    Local $aHit = _GUICtrlListView_SubItemHitTest($hListView)
                    If ($aHit[0] <> -1) And ($aHit[1] > 0) Then
                        $Item = $aHit[0]
                        $SubItem = $aHit[1]
                        Local $iSubItemText = _GUICtrlListView_GetItemText($hListView, $Item, $SubItem)
                        Local $aRect = _GUICtrlListView_GetSubItemRect($hListView, $Item, $SubItem)
                        $hEdit = _GUICtrlEdit_Create($hGUI, $iSubItemText, $aRect[0] + 1, $aRect[1] - 4, $aRect[2] - $aRect[0], 20, $Style)
                        _WinAPI_SetFocus($hEdit)
                    EndIf
            EndSwitch
    EndSwitch
        
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $iCode = BitShift($wParam, 16)
    
    Switch $lParam
        Case $hEdit
            Switch $iCode
                Case $EN_KILLFOCUS
                    Local $iText = _GUICtrlEdit_GetText($hEdit)
                    _GUICtrlListView_SetItemText($hListView, $Item, $iText, $SubItem)
                    _WinAPI_DestroyWindow($hEdit)
                    $Item = -1
                    $SubItem = 0
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc

muttley

Edited by rasim
Link to comment
Share on other sites

Hi,

Nice work, I always wondered how to in place edit sub items muttley

I added a little more to it to make it look uniform.

#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>

Opt("GuiCloseOnESC", 0)

Global $hEdit, $hDC, $hBrush, $Item = -1, $SubItem = 0

Global $Style = BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT)

$hGUI = GUICreate("ListView Subitems edit in place", 300, 200)

$hListView = _GUICtrlListView_Create($hGUI, "Items|SubItems", 2, 2, 296, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_GRIDLINES)

For $i = 1 To 10
    _GUICtrlListView_AddItem($hListView, "Item " & $i)
    _GUICtrlListView_AddSubItem($hListView, $i - 1, "SubItem " & $i, 1)
Next

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tNMHDR, $hWndFrom, $iCode

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
   
    Switch $hWndFrom
        Case $hListView
            Switch $iCode
                Case $NM_DBLCLK
                    Local $aHit = _GUICtrlListView_SubItemHitTest($hListView)
                    If ($aHit[0] <> -1) And ($aHit[1] > 0) Then
                        $Item = $aHit[0]
                        $SubItem = $aHit[1]
                        Local $iSubItemText = _GUICtrlListView_GetItemText($hListView, $Item, $SubItem)
                        Local $iLen = _GUICtrlListView_GetStringWidth($hListView, $iSubItemText)
                        Local $aRect = _GUICtrlListView_GetSubItemRect($hListView, $Item, $SubItem)
                        $hEdit = _GUICtrlEdit_Create($hGUI, $iSubItemText, $aRect[0] + 6, $aRect[1], $iLen + 10, 17, $Style)
                        _GUICtrlEdit_SetSel($hEdit, 0, -1)
                        _WinAPI_SetFocus($hEdit)
                        $hDC = _WinAPI_GetWindowDC($hEdit)
                        $hBrush = _WinAPI_CreateSolidBrush(0)
                        FrameRect($hDC, 0, 0, $iLen + 10 , 17, $hBrush)
                        
                    EndIf
            EndSwitch
    EndSwitch
       
    Return $GUI_RUNDEFMSG
EndFunc

Func FrameRect($hDC, $nLeft, $nTop, $nRight, $nBottom, $hBrush)
    Local $stRect = DllStructCreate("int;int;int;int")
    
    DllStructSetData($stRect, 1, $nLeft)
    DllStructSetData($stRect, 2, $nTop)
    DllStructSetData($stRect, 3, $nRight)
    DllStructSetData($stRect, 4, $nBottom)
    
    DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush)
EndFunc

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $iCode = BitShift($wParam, 16)
   
    Switch $lParam
        Case $hEdit
            Switch $iCode
                Case $EN_KILLFOCUS
                    Local $iText = _GUICtrlEdit_GetText($hEdit)
                    _GUICtrlListView_SetItemText($hListView, $Item, $iText, $SubItem)
                    _WinAPI_DeleteObject($hBrush)
                    _WinAPI_ReleaseDC($hEdit, $hDC)
                    _WinAPI_DestroyWindow($hEdit)
                    
                    $Item = -1
                    $SubItem = 0
            EndSwitch
    EndSwitch
   
    Return $GUI_RUNDEFMSG
EndFunc

Cheers

Edited by smashly
Link to comment
Share on other sites

Hi,

here another way for this:

#include<StaticConstants.au3>
#include<GUIConstantsEx.au3>
#include<ListViewConstants.au3>
#include<StructureConstants.au3>
#include<WindowsConstants.au3>
#include <GUIListView.au3>
Opt("GUIOnEventMode", 1)
Global $currentItem[2], $title

$gui = GUICreate('test')
GUISetOnEvent($GUI_EVENT_CLOSE, '_ende')
$hListView = GUICtrlCreateListView('Column1|Column2|Column3', 10, 10, 300, 200, $LVS_REPORT)
_GUICtrlListView_SetColumnWidth($hListView, 0, 70)
_GUICtrlListView_SetColumnWidth($hListView, 1, 60)
_GUICtrlListView_SetColumnWidth($hListView, 2, $LVSCW_AUTOSIZE_USEHEADER )
For $i = 1 To 9
    GUICtrlCreateListViewItem('R. ' & $i & ' - Col. 1|R. ' & $i & ' - Col. 2|R. ' & $i & ' - Col. 3', $hListView)
Next

$EditBox = GUICreate('', 200, 30, -1, -1, BitOR($WS_POPUP,$WS_BORDER), $WS_EX_TOPMOST)
$edit = GUICtrlCreateInput('', 5, 5, 190, 20, $SS_CENTER)
GUICtrlSetOnEvent(-1, '_EditEnter')
HotKeySet('{ESC}', '_escEdit')

GUISetState(@SW_SHOW, $gui)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While True
    Sleep(100)
WEnd

Func _LeftDblClick($Info)
    If $Info[3] = -1 Then Return
    _GUICtrlListView_SetSelectedColumn($Info[1], $Info[4])
    $title = WinGetTitle($gui)
    Local $mouse = MouseGetPos(), $wndEdit = WinGetPos($EditBox)
    Local $wndGUI = WinGetPos($gui), $wndLV = ControlGetPos($gui, '', $hListView)
    Local $colInfo = _GUICtrlListView_GetColumn($Info[1], $Info[4]), $sumWidth = 0, $tmp
    WinSetTitle($gui, '', 'Edit: Row ' & $Info[3]+1 & ', ' & $colInfo[5])
    For $i = 0 To $Info[4]
        $tmp = _GUICtrlListView_GetColumn($Info[1], $i)
        $sumWidth += $tmp[4]
    Next
    $sumWidth -= $colInfo[4]
    Local $xPos = $wndGUI[0]+$wndLV[0]+$sumWidth
    If $xPos+$colInfo[4]+10 > @DesktopWidth Then $xPos = @DesktopWidth - ($colInfo[4] + 10)
    If $xPos < 0 Then $xPos = 0
    WinMove($EditBox, '', $xPos, $mouse[1]-$wndEdit[3], $colInfo[4]+10)
    GUICtrlSetData($edit, _GUICtrlListView_GetItemText($Info[1], $Info[3], $Info[4]))
    $currentItem[0] = $Info[3]
    $currentItem[1] = $Info[4]
    GUISetState(@SW_SHOW, $EditBox)
EndFunc

Func _escEdit()
    WinSetTitle($gui, '', $title)
    GUISetState(@SW_HIDE, $EditBox)
EndFunc

Func _EditEnter()
    WinSetTitle($gui, '', $title)
    _GUICtrlListView_SetItemText($hListView, $currentItem[0], GUICtrlRead($edit), $currentItem[1])
    GUISetState(@SW_HIDE, $EditBox)
EndFunc

Func _ende()
    Exit
EndFunc

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    Local $aInfo[5] = [$hWndFrom, $iIDFrom, $iCode, DllStructGetData($tInfo, "Index"), _
                                        DllStructGetData($tInfo, "SubItem")]
                    _LeftDblClick($aInfo)
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Best Regards BugFix  

Link to comment
Share on other sites

So, I found that rasim's and smashly's code worked very well for one listview control, and i started thinking about how to make it work with two listview controls.

I know there is a alot of duplication in the WM_Notify function that follows, but it does seem to work with the two listview controls.

The problem I'm having now is trying to figure out how to make the WM_Command function work with two controls. No matter what I've tried I can't seem to find the handle for the listview control that is being edited.

Any ideas about how to make the WM_Command function work for both hListView and hListView2?

Thank you,

DiscoEd

#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
#include <GuiListView.au3>;Added by DiscoEd
#include <GUIConstantsEx.au3>;Added by DiscoEd

Opt("GuiCloseOnESC", 0)

Global $hEdit, $hDC, $hBrush, $Item = -1, $SubItem = 0

Global $Style = BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT)

$hGUI = GUICreate("ListView Subitems edit in place", 300, 500)

$hListView = _GUICtrlListView_Create ($hGUI, "Items|SubItems|SubItems2", 2, 2, 296, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle ($hListView, $LVS_EX_GRIDLINES)

$hListView2 = _GUICtrlListView_Create ($hGUI, "Items|SubItems|SubItems2", 2, 210, 296, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle ($hListView2, $LVS_EX_GRIDLINES)


For $i = 1 To 10
    _GUICtrlListView_AddItem ($hListView, "Item " & $i)
    _GUICtrlListView_AddSubItem ($hListView, $i - 1, "SubItem " & $i, 1)
    _GUICtrlListView_AddSubItem ($hListView, $i - 1, "SubItem " & $i, 2)
    _GUICtrlListView_AddItem ($hListView2, "Item " & $i)
    _GUICtrlListView_AddSubItem ($hListView2, $i - 1, "SubItem " & $i, 1)
    _GUICtrlListView_AddSubItem ($hListView2, $i - 1, "SubItem " & $i, 2)

Next

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tNMHDR, $hWndFrom, $iCode

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hListView
            Switch $iCode
                Case $NM_DBLCLK
                    Local $aHit = _GUICtrlListView_SubItemHitTest ($hListView)
                    If ($aHit[0] <> -1) And ($aHit[1] > 0) Then
                        $Item = $aHit[0]
                        $SubItem = $aHit[1]
                        Local $iSubItemText = _GUICtrlListView_GetItemText ($hListView, $Item, $SubItem)
                        Local $iLen = _GUICtrlListView_GetStringWidth ($hListView, $iSubItemText)
                        Local $aRect = _GUICtrlListView_GetSubItemRect ($hListView, $Item, $SubItem)
                        $hEdit = _GUICtrlEdit_Create ($hGUI, $iSubItemText, $aRect[0] + 6, $aRect[1], $iLen + 10, 17, $Style)
                        _GUICtrlEdit_SetSel ($hEdit, 0, -1)
                        _WinAPI_SetFocus ($hEdit)
                        $hDC = _WinAPI_GetWindowDC ($hEdit)
                        $hBrush = _WinAPI_CreateSolidBrush (0)
                        FrameRect($hDC, 0, 0, $iLen + 10, 17, $hBrush)

                    EndIf
            EndSwitch
        Case $hListView2
            Switch $iCode
                Case $NM_DBLCLK
                    Local $aHit = _GUICtrlListView_SubItemHitTest ($hListView2)
                    If ($aHit[0] <> -1) And ($aHit[1] > 0) Then
                        $Item = $aHit[0]
                        $SubItem = $aHit[1]
                        Local $iSubItemText = _GUICtrlListView_GetItemText ($hListView2, $Item, $SubItem)
                        Local $iLen = _GUICtrlListView_GetStringWidth ($hListView2, $iSubItemText)
                        Local $aRect = _GUICtrlListView_GetSubItemRect ($hListView2, $Item, $SubItem)
                        $hEdit = _GUICtrlEdit_Create ($hGUI, $iSubItemText, $aRect[0] + 6, $aRect[1], $iLen + 10, 17, $Style)
                        _GUICtrlEdit_SetSel ($hEdit, 0, -1)
                        _WinAPI_SetFocus ($hEdit)
                        $hDC = _WinAPI_GetWindowDC ($hEdit)
                        $hBrush = _WinAPI_CreateSolidBrush (0)
                        FrameRect($hDC, 0, 0, $iLen + 10, 17, $hBrush)

                    EndIf
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc  ;==>WM_NOTIFY

Func FrameRect($hDC, $nLeft, $nTop, $nRight, $nBottom, $hBrush)
    Local $stRect = DllStructCreate("int;int;int;int")

    DllStructSetData($stRect, 1, $nLeft)
    DllStructSetData($stRect, 2, $nTop)
    DllStructSetData($stRect, 3, $nRight)
    DllStructSetData($stRect, 4, $nBottom)

    DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush)
EndFunc  ;==>FrameRect

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $iCode = BitShift($wParam, 16)

               ;<<<<< ---- CAN I GET THE LISTVIEW CONTROL HANDLE FROM THE WM_COMMAND PARAMETERS AND USE IT IN A SWITCH HERE?

    Switch $lParam
        Case $hEdit
            Switch $iCode
                Case $EN_KILLFOCUS
                    Local $iText = _GUICtrlEdit_GetText ($hEdit)
                    _GUICtrlListView_SetItemText ($hListView, $Item, $iText, $SubItem)
                    _WinAPI_DeleteObject ($hBrush)
                    _WinAPI_ReleaseDC ($hEdit, $hDC)
                    _WinAPI_DestroyWindow ($hEdit)

                    $Item = -1
                    $SubItem = 0
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc  ;==>WM_COMMAND
Link to comment
Share on other sites

  • 4 years later...

Hi,

Thanks it's just what i'm looking for !!

I added some details in it :

- Press "Enter" to close the editbox

- Editbox follow the listview when you change its position.

#include <GuiConstants.au3>
#include <GuiEdit.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>

Opt("GuiCloseOnESC", 0)

Global $hEdit, $hDC, $hBrush, $Item = -1, $SubItem = 0

Global $Style = BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT)

$hGUI = GUICreate("ListView Subitems edit in place", 370, 280)

$hNM_DBCLK = GUICtrlCreateDummy()
$hEN_KILLFOCUS = GUICtrlCreateDummy()

$hListView = _GUICtrlListView_Create($hGUI, "test1|test2", 32, 35, 300, 214)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_AUTOARRANGE,$LVS_EX_FULLROWSELECT,$LVS_EX_DOUBLEBUFFER,$LVS_EX_SUBITEMIMAGES))

For $i = 1 To 10
_GUICtrlListView_AddItem($hListView, "Item " & $i)
_GUICtrlListView_AddSubItem($hListView, $i - 1, "SubItem " & $i, 1)
Next

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        case $hNM_DBCLK
            Start_EditingLV()
        Case $hEN_KILLFOCUS
            End_EditingLV()
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR, $hWndFrom, $iCode

$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
$iCode = DllStructGetData($tNMHDR, "Code")

Switch $hWndFrom
Case $hListView
Switch $iCode
Case $NM_DBLCLK
                    GUICtrlSendToDummy($hNM_DBCLK)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc

Func FrameRect($hDC, $nLeft, $nTop, $nRight, $nBottom, $hBrush)


Local $stRect = DllStructCreate("int;int;int;int")

DllStructSetData($stRect, 1, $nLeft)
DllStructSetData($stRect, 2, $nTop)
DllStructSetData($stRect, 3, $nRight)
DllStructSetData($stRect, 4, $nBottom)

DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush)
EndFunc

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
Local $iCode = BitShift($wParam, 16)

Switch $lParam
Case $hEdit
Switch $iCode
Case $EN_KILLFOCUS
                    GUICtrlSendToDummy($hEN_KILLFOCUS)
EndSwitch
EndSwitch

Return $GUI_RUNDEFMSG
EndFunc

Func Start_EditingLV()
    ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hListView)))

    Local $aHit = _GUICtrlListView_SubItemHitTest($hListView)
    Local $hRect = ControlGetPos($hGUI, "", $hListView)

    If ($aHit[0] <> -1) And ($aHit[1] = 0) Then
        $Item = $aHit[0]
        $SubItem = 0
        Local $aRect = _GUICtrlListView_GetItemRect($hListView, $Item)
    ElseIf ($aHit[0] <> -1) And ($aHit[1] > 0) Then
        $Item = $aHit[0]
        $SubItem = $aHit[1]
        Local $aRect = _GUICtrlListView_GetSubItemRect($hListView, $Item, $SubItem)
    Else
        Return $GUI_RUNDEFMSG
    EndIf

    Local $iItemText = _GUICtrlListView_GetItemText($hListView, $Item, $SubItem)
    Local $iLen = _GUICtrlListView_GetStringWidth($hListView, $iItemText)
    $hEdit = _GUICtrlEdit_Create($hGUI, $iItemText, $aRect[0] + ($hRect[0] + 3), $aRect[1] + $hRect[1], $iLen + 10, 17, $Style)

    _GUICtrlEdit_SetSel($hEdit, 0, -1)
    _WinAPI_SetFocus($hEdit)
    $hDC = _WinAPI_GetWindowDC($hEdit)
    $hBrush = _WinAPI_CreateSolidBrush(0x0000FF)
    FrameRect($hDC, 0,0, $iLen + 10 , 17, $hBrush)
    HotKeySet("{ENTER}", "End_EditingLV")

EndFunc
Func End_EditingLV()
    Local $iText = _GUICtrlEdit_GetText($hEdit)
    _GUICtrlListView_SetItemText($hListView, $Item, $iText, $SubItem)
    _WinAPI_DeleteObject($hBrush)
    _WinAPI_ReleaseDC($hEdit, $hDC)
    _WinAPI_DestroyWindow($hEdit)
    ControlEnable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hListView)))

    $Item = -1
    $SubItem = 0
    HotKeySet("{ENTER}")
EndFunc

I know this post is old but maybe this can help anyone.

Edited by M4n0x
Link to comment
Share on other sites

@M4n0x

Nice little bit there. I was looking for such a feature yesterday and your posting brought this to my attention. Thanks.

One thing, I like they way your method keeps the input box as a "cell" rather than a popup type overlay. And I like how the enter button commits the edits. However, I cannot seem to figure out how to convert it to use OnEvent. Things get wonky with the hotkey and enter, but works fine without that. Actually if you just convert it all to OnEvent, the end_editLV runs twice and the second time through clears the value out.

Any ideas?

Link to comment
Share on other sites

  • 1 year later...
  • Moderators

faustf,

As far as I know you need to add an empty item to a ListView before you can edit it - no item means no edit. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

qwert,

My GUIListViewEx UDF allows you to drag entire rows within and between ListViews - perhaps the code might offer some ideas on how you might drag single sub-items. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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