Sign in to follow this  
Followers 0
nullschritt

Drop Down list in listview

9 posts in this topic

Hello all, I was wondering if there was a way to put drop down lists in a list view?

So that say for example, I have a listview of users, and want a drop down in the same row as each user, to select a custom key to be assigned to that user?

like so(this image is photoshopped):

VcHIteI.png

Share this post


Link to post
Share on other sites



nullschritt,

My GUIListViewEx offers that exact functionality - the link is in my sig and you need to look at Example 2. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

nullschritt,

My GUIListViewEx offers that exact functionality - the link is in my sig and you need to look at Example 2. :)

M23

Sorry, but, I don't see anything in example 2 that adds a drop down to a listview? Or is there a specific function in the code that could be used to add a listview that I've missed?

Share this post


Link to post
Share on other sites

nullschritt,

Run "GLVEx_Example_2.au3", click through the 2 dialogs and double-click on an item in the left-hand ListView - a combo will appear and selecting from it will replace the ListView item with the chosen value. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

nullschritt,

Run "GLVEx_Example_2.au3", click through the 2 dialogs and double-click on an item in the left-hand ListView - a combo will appear and selecting from it will replace the ListView item with the chosen value. :)

M23

Okay, I see it now.

 

However I'm having a small problem. I need to have two columns in the list view, with only the second editable.

 

I've extracted the code needed to modify the values, and modified it some, but it's only showing a single column in the listview, even though I've told it to make two.

 

Can you tell me what I'm doing wrong?

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

#include <Array.au3> ; Just for display in example

Global $iCount_Left = 20, $iCount_Right = 20, $vData, $aRet, $iEditMode = 0

; Create GUI
$hGUI = GUICreate("LVEx Example 2", 290, 410)

; Create Left ListView
GUICtrlCreateLabel("Native ListView" & @CRLF & "Single selection - count element - editable", 10, 5, 300, 35)
$cListView_Left = GUICtrlCreateListView("User|Encryption Key", 10, 40, 250, 300)
_GUICtrlListView_SetExtendedListViewStyle($cListView_Left, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView_Left, 0, 229)

; Create array and fill Left listview
Global $aLV_List_Left[$iCount_Left + 1] = [$iCount_Left]
For $i = 1 To UBound($aLV_List_Left) - 1
    $aLV_List_Left[$i] = "Tom "& $i - 1& "|Key1"
    GUICtrlCreateListViewItem($aLV_List_Left[$i], $cListView_Left)
Next

; Initiate LVEx - count parameter set - blue insert mark- no drag image - editable  - all columns editable by default
$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 1, 0x0000FF, False, 2 + 16 + 32)

_GUIListViewEx_ComboData($iLV_Left_Index, 0, "Key1|Key2|Key3")

_GUIListViewEx_MsgRegister()
GUISetState(@SW_SHOW)
while 1
        Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch

    $aRet = _GUIListViewEx_EditOnClick($iEditMode)

    sleep(10)

WEnd
Edited by nullschritt

Share this post


Link to post
Share on other sites

nullschritt,

You still had the first column width set to wider than the ListView - so hardly surprising that you did not see the second column. ;)

And to make only the second column editable, set the column in both _GUIListViewEx_Init & _GUIListViewEx_ComboData - like this:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

Global $iCount = 20, $iCount_Right = 20, $iEditMode = 0

; Create GUI
$hGUI = GUICreate("Combo Example", 290, 410)

; Create ListView
$cListView = GUICtrlCreateListView("User|Encryption Key", 10, 40, 250, 300)
_GUICtrlListView_SetExtendedListViewStyle($cListView, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView, 0, 100) ; Reduce col width <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; Create array and fill listview
Global $aLV_List[$iCount + 1] = [$iCount]
For $i = 1 To UBound($aLV_List) - 1
    $aLV_List[$i] = "Tom " & $i - 1 & "|Key1"
    GUICtrlCreateListViewItem($aLV_List[$i], $cListView)
Next

; Initiate LVEx - count parameter set - blue insert mark- no drag image - editable  - all columns editable by default
$iLV_Index = _GUIListViewEx_Init($cListView, $aLV_List, 1, 0x0000FF, False, 2 + 32, "1") ; Set column 1 to be editable <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

_GUIListViewEx_ComboData($iLV_Index, 1, "Key1|Key2|Key3") ; Set the values for the combo in column 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

_GUIListViewEx_MsgRegister()

GUISetState(@SW_SHOW)
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    _GUIListViewEx_EditOnClick($iEditMode)
WEnd
All clear now? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

nullschritt,

You still had the first column width set to wider than the ListView - so hardly surprising that you did not see the second column. ;)

And to make only the second column editable, set the column in both _GUIListViewEx_Init & _GUIListViewEx_ComboData - like this:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

Global $iCount = 20, $iCount_Right = 20, $iEditMode = 0

; Create GUI
$hGUI = GUICreate("Combo Example", 290, 410)

; Create ListView
$cListView = GUICtrlCreateListView("User|Encryption Key", 10, 40, 250, 300)
_GUICtrlListView_SetExtendedListViewStyle($cListView, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView, 0, 100) ; Reduce col width <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; Create array and fill listview
Global $aLV_List[$iCount + 1] = [$iCount]
For $i = 1 To UBound($aLV_List) - 1
    $aLV_List[$i] = "Tom " & $i - 1 & "|Key1"
    GUICtrlCreateListViewItem($aLV_List[$i], $cListView)
Next

; Initiate LVEx - count parameter set - blue insert mark- no drag image - editable  - all columns editable by default
$iLV_Index = _GUIListViewEx_Init($cListView, $aLV_List, 1, 0x0000FF, False, 2 + 32, "1") ; Set column 1 to be editable <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

_GUIListViewEx_ComboData($iLV_Index, 1, "Key1|Key2|Key3") ; Set the values for the combo in column 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

_GUIListViewEx_MsgRegister()

GUISetState(@SW_SHOW)
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    _GUIListViewEx_EditOnClick($iEditMode)
WEnd
All clear now? :)

M23

 

Sure is! I feel dumb now :P Sorry, I'm pretty tired!

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Having another problem now....
 
Whenever I call _GUIListViewEx_MsgRegister()
 
It unsets my previous call to GUIRegisterMsg()
 
Edit: I've tried simply copying and pasting the code from your function into my wm_notify command, but when I compile and run it gives me an error about a variable not being declared.... even though when I run without compiling I get no such error.... very frustrating.

EditEdit: Nevermind, I found the problem. thanks for the great UDF!

Edited by nullschritt

Share this post


Link to post
Share on other sites

nullschritt,

Glad you got it sorted. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0