Jump to content

Editable List View Item


Recommended Posts

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

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:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

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:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

  • Moderators

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:

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

@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:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

  • Moderators

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:

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

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:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

  • Moderators

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:

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

  • 4 years later...
On 3/25/2016 at 3: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

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

Link to comment
Share on other sites

  • Moderators

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:

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

  • 2 weeks later...
  • Moderators

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:

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

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

  • Moderators

maniootek,

Quote

Any idea

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:

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

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

How is that?

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?

Link to comment
Share on other sites

  • Moderators

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:

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