Jump to content

Recommended Posts

Posted (edited)

I have made this part of code

#include <GUIConstantsEx.au3> ;for $GUI_EVENT_CLOSE
#include <GuiListView.au3> ; for $iExListViewStyle
#include <Array.au3>
Example()

Func Example()
    GUICreate("listview items", 220, 250, 100, 200, -1)
    Local $idListview = GUICtrlCreateListView("col1|col2|col3  ", 10, 10, 200, 150)

    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES,  $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iExListViewStyle)

    Local $aIDitem[0]
    for $i=0 to 5
        _ArrayAdd($aIDitem, GUICtrlCreateListViewItem($i & "|name|1" , $idListview))
    Next

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
EndFunc

how can i make cell "1" editable like this:

 

listview.png

Edited by maniootek
Posted

also here:

 

 

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Yes i found this but this is so heavy part of code for me which I can't manage. I would rather get to know about some style or something what make it editable

Posted

There is no other easier way - or at least I do not know any one.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • Moderators
Posted

maniootek,

My UDF is not that hard to use:

#include <GUIConstantsEx.au3> ;for $GUI_EVENT_CLOSE
#include <GuiListViewEx.au3> ; for $iExListViewStyle
#include <Array.au3>

Example()

Func Example()
    GUICreate("listview items", 220, 250, 100, 200, -1)
    Local $idListview = GUICtrlCreateListView("col1|col2|col3  ", 10, 10, 200, 150)

    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iExListViewStyle)

    Local $aArray[6]
    for $i=0 to 5
        $aArray[$i] = $i & "|name|1"
        GUICtrlCreateListViewItem($i & "|name|1" , $idListview)
    Next

    $cButton = GUICtrlCreateButton("Read ListView", 10, 200, 80, 30)

    GUISetState(@SW_SHOW)

    $iLV_Index = _GUIListViewEx_Init($idListview, $aArray, 0, 0, True, 2, "2")

    _GUIListViewEx_MsgRegister(True, False, False)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $cButton
                $aRead = _GUIListViewEx_ReturnArray($iLV_Index)
                _ArrayDisplay($aRead, "Content", Default, 8)
                $aRead = _GUIListViewEx_ReturnArray($iLV_Index, 1)
                _ArrayDisplay($aRead, "Checkboxes", Default, 8)

        EndSwitch

        _GUIListViewEx_EditOnClick(0)
        
    WEnd
EndFunc

Please in the forum (rather than by PM) ask if you have any questions.

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:

  Reveal hidden contents

 

Posted

@Melba23 Thanks for this example.

I want to ask is this know issue that when I edit value and without pressing ENTER just click on another ListView Item then this edited value is not "Saved".
Can this be fixed to store edited value when I changed focus by mouse clicking ?

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • Moderators
Posted

mLipok,

Perhaps reading the detailed UDF function headers I spent a lot of time writing might provide a clue.....

; #FUNCTION# =========================================================================================================
; Name...........: _GUIListViewEx_Init
[...]
;                  $iAdded  - 0     - No added features (default).  To get added features add the following
;                             + 1   - Sortable by clicking on column headers (if not user colour enabled)
;                             + 2   - Editable when double clicking on a subitem in user-defined columns                      <<<<<<
;                             + 4   - Edit continues within same ListView by triple mouse-click (only if ListView editable)   <<<<<<

So if you initiate the ListView like this:

$iLV_Index = _GUIListViewEx_Init($idListview, $aArray, 0, 0, True, 2 + 4, "2")

you will find that the edit will be accepted if you click elsewhere.

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:

  Reveal hidden contents

 

Posted

My fault, as my reading feature is not perfect ;)

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • Moderators
Posted

mLipok,

No problems - I realise this UDF is a pretty complex beast and I am always happy to explain how it works.

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:

  Reveal hidden contents

 

  • 4 years later...
Posted
  On 3/25/2016 at 2:24 PM, Melba23 said:

maniootek,

My UDF is not that hard to use:

#include <GUIConstantsEx.au3> ;for $GUI_EVENT_CLOSE
#include <GuiListViewEx.au3> ; for $iExListViewStyle
#include <Array.au3>

Example()

Func Example()
    GUICreate("listview items", 220, 250, 100, 200, -1)
    Local $idListview = GUICtrlCreateListView("col1|col2|col3  ", 10, 10, 200, 150)

    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iExListViewStyle)

    Local $aArray[6]
    for $i=0 to 5
        $aArray[$i] = $i & "|name|1"
        GUICtrlCreateListViewItem($i & "|name|1" , $idListview)
    Next

    $cButton = GUICtrlCreateButton("Read ListView", 10, 200, 80, 30)

    GUISetState(@SW_SHOW)

    $iLV_Index = _GUIListViewEx_Init($idListview, $aArray, 0, 0, True, 2, "2")

    _GUIListViewEx_MsgRegister(True, False, False)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $cButton
                $aRead = _GUIListViewEx_ReturnArray($iLV_Index)
                _ArrayDisplay($aRead, "Content", Default, 8)
                $aRead = _GUIListViewEx_ReturnArray($iLV_Index, 1)
                _ArrayDisplay($aRead, "Checkboxes", Default, 8)

        EndSwitch

        _GUIListViewEx_EditOnClick(0)
        
    WEnd
EndFunc

Please in the forum (rather than by PM) ask if you have any questions.

M23

Expand  

Can you convert this code to make it compatible with latest UDF version?

  • Moderators
Posted

maniootek,

Sorry for the delay in replying - the real world got rather busy.

#include <GUIConstantsEx.au3> ;for $GUI_EVENT_CLOSE
#include <GuiListViewEx.au3> ; for $iExListViewStyle
#include <Array.au3>

Example()

Func Example()
    GUICreate("listview items", 220, 250, 100, 200, -1)
    Local $idListview = GUICtrlCreateListView("col1|col2|col3  ", 10, 10, 200, 150)

    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iExListViewStyle)

    Local $aArray[6]
    for $i=0 to 5
        $aArray[$i] = $i & "|name|1"
        GUICtrlCreateListViewItem($i & "|name|1" , $idListview)
    Next

    $cButton = GUICtrlCreateButton("Read ListView", 10, 200, 80, 30)

    GUISetState(@SW_SHOW)

    $iLV_Index = _GUIListViewEx_Init($idListview, $aArray, 0, 0, True, 2) ; Use correct number of parameters here <<<<<<<<<<<<<

    _GUIListViewEx_SetEditStatus($iLV_Index, "2") ; Set editable column here <<<<<<<<<<<<<<<<<<

    _GUIListViewEx_MsgRegister(True, False, False)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $cButton
                $aRead = _GUIListViewEx_ReturnArray($iLV_Index)
                _ArrayDisplay($aRead, "Content", Default, 8)
                $aRead = _GUIListViewEx_ReturnArray($iLV_Index, 1)
                _ArrayDisplay($aRead, "Checkboxes", Default, 8)

        EndSwitch

        _GUIListViewEx_EventMonitor() ; Use correct monitor function here <<<<<<<<<<<<<<<<<<<

    WEnd
EndFunc

That should do you!

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:

  Reveal hidden contents

 

  • 2 weeks later...
  • Moderators
Posted

maniootek,

You could determine the size of the new content with my StringSize UDF and adjust the ListView and GUI accordingly - something like this perhaps:

#include <GUIConstantsEx.au3>
#include <GuiListViewEx_Test.au3>
#include <Array.au3>

#include "StringSize.au3"

$iWidth = 200

Example()

Func Example()
    $hGUI = GUICreate("listview items", $iWidth + 20, 250, 100, 200, -1)
    Local $idListview = GUICtrlCreateListView("col1|col2|col3  ", 10, 10, $iWidth, 150)

    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iExListViewStyle)

    GUICtrlSetFont($idListview, 10, 0, 0)

    Local $aArray[6]
    for $i=0 to 5
        $aArray[$i] = $i & "|name|1"
        GUICtrlCreateListViewItem($i & "|name|1" , $idListview)
    Next

    $cButton = GUICtrlCreateButton("Read ListView", 10, 200, 80, 30)

    GUISetState(@SW_SHOW)

    $iLV_Index = _GUIListViewEx_Init($idListview, $aArray, 0, 0, True, 2)
    _GUIListViewEx_SetEditStatus($iLV_Index, "2")

    _GUIListViewEx_MsgRegister(True, False, False)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $cButton
                $aRead = _GUIListViewEx_ReturnArray($iLV_Index)
                _ArrayDisplay($aRead, "Content", Default, 8)
                $aRead = _GUIListViewEx_ReturnArray($iLV_Index, 1)
                _ArrayDisplay($aRead, "Checkboxes", Default, 8)

        EndSwitch

        $vRet = _GUIListViewEx_EventMonitor()
        ; Check there was a valid edit return
        If @extended = 1 And IsArray($vRet) Then
            ; Get the size of the inserted string
            $aRet = _StringSize($vRet[1][3], 10)
            ; Gte the present column width
            $iColWidth = _GUICtrlListView_GetColumnWidth($idListview, 2)
            ; Now see if we need to expand the column and GUI
            If $aRet[2] > $iColWidth - 15 Then
                _GUICtrlListView_SetColumnWidth($idListview, 2, $aRet[2] + 15) ; You need a margin
                $iDiff = $aRet[2] + 5 - $iColWidth
                $aWinPos = WinGetPos($hGUI)
                WinMove($hGUI, "", Default, Default, $aWinPos[2] + $iDiff)
            EndIf
        EndIf

    WEnd
EndFunc

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:

  Reveal hidden contents

 

Posted (edited)

This is good example of the auto gui and listview column resize during cell editing.

What about autofit before editing? During gui and listview creation according to the data in the list view? Any idea or ready function?

Edited by maniootek
  • Moderators
Posted

maniootek,

  Quote

Any idea

Expand  

But of course!

#include <GUIConstantsEx.au3>
#include <GuiListViewEx.au3>
#include <Array.au3>

#include "StringSize.au3"

Global $iWidth = 200, $iTextSize = 10

Example()

Func Example()
    $hGUI = GUICreate("listview items", $iWidth + 20, 250, 100, 200, -1)
    Local $idListview = GUICtrlCreateListView("col1|col2|col3  ", 10, 10, $iWidth, 150)

    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iExListViewStyle)

    GUICtrlSetFont($idListview, $iTextSize, 0, 0)

    Local $aArray[6]
    For $i = 0 To 5
        $aArray[$i] = $i & "|name|1"
        GUICtrlCreateListViewItem($i & "|name|1", $idListview)
    Next

    $cButton = GUICtrlCreateButton("Read ListView", 10, 200, 80, 30)

    GUISetState(@SW_SHOW)

    $iLV_Index = _GUIListViewEx_Init($idListview, $aArray, 0, 0, True, 2)
    _GUIListViewEx_SetEditStatus($iLV_Index, "2")

    _GUIListViewEx_MsgRegister(True, False, False)

    ; Resize column to match input (not necessasry in this case but colud be if you were entering more varied data)
    _ColumnResizer($hGUI, $idListview, $iLV_Index)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $cButton
                $aRead = _GUIListViewEx_ReturnArray($iLV_Index)
                _ArrayDisplay($aRead, "Content", Default, 8)
                $aRead = _GUIListViewEx_ReturnArray($iLV_Index, 1)
                _ArrayDisplay($aRead, "Checkboxes", Default, 8)

        EndSwitch

        $vRet = _GUIListViewEx_EventMonitor()
        ; Check there was a valid edit return
        If @extended = 1 And IsArray($vRet) Then
            ; Resize column to fit new data
            _ColumnResizer($hGUI, $idListview, $iLV_Index)
        EndIf

    WEnd
EndFunc   ;==>Example

Func _ColumnResizer($hGUI, $idListview, $iLV_Index)

    Local $iMaxWidth = 50

    ; Read content
    $aRead = _GUIListViewEx_ReturnArray($iLV_Index, 3)
    ; Loop through elements to find longest
    For $i = 0 To UBound($aRead) - 1
        ; Get the size of the string
        $aRet = _StringSize($aRead[$i][2], $iTextSize)
        ; And check to see if it is the biggest yet
        If $aRet[2] + 15 > $iMaxWidth Then
            ; Reset max width
            $iMaxWidth = $aRet[2] + 15
        EndIf
    Next
    ; Now get current column width
    $iColWidth = _GUICtrlListView_GetColumnWidth($idListview, 2)
    ; And reset it
    _GUICtrlListView_SetColumnWidth($idListview, 2, $iMaxWidth)
    ; Now check on the change we just made
    $iDiff = $iMaxWidth - $iColWidth
    ; And adjust GUI to fit
    $aWinPos = WinGetPos($hGUI)
    WinMove($hGUI, "", Default, Default, $aWinPos[2] + $iDiff)

EndFunc   ;==>_ColumnResizer

How is that?

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:

  Reveal hidden contents

 

Posted
  On 9/25/2020 at 3:54 PM, Melba23 said:

How is that?

Expand  

Thank you. This working good for one column. I was looking for some function which will auto resize ALL columns according to the content and headers and also resize gui. I have enought examples to do it myself but I was wondering if there is any ready function?

  • Moderators
Posted

maniootek,

Look at the _GUICtrlListView_SetColumnWidth function - and the use of the $LVSCW_AUTOSIZE width parameter. This is what _ArrayDisplay does to make the GUI auto-size.

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:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

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