Jump to content
faustf

listview + checkbox only one flag

Recommended Posts

faustf

hi guy

i have  a listview with checkbox  , is possible ,  not flag  many  checkbox in contemporary ?

thankz  at all

 

Share this post


Link to post
Share on other sites
MikahS

You'll need to explain a little more, unless someone else can understand what you're asking.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Melba23

faustf,

Do you mean that you only want to allow a single item in the ListView to be checked at any one time?

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
faustf

yea  , dont  want  flag  in the same  time  2 or  more  checkbox  only  one

 

Share this post


Link to post
Share on other sites
Melba23

faustf,

This seems to work:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

Global $iChecked = -1

$hGUI = GUICreate("Test", 500, 500)

$cLV = GUICtrlCreateListView("Column 0", 10, 10, 300, 300, BitOr($LVS_SHOWSELALWAYS, $LVS_SINGLESEL))
_GUICtrlListView_SetExtendedListViewStyle($cLV, BitOr($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))

For $i = 0 To 9
    GUICtrlCreateListViewItem("Item " & $i, $cLV)
Next

$cLVClicK_Dummy = GUICtrlCreateDummy()

GUISetState()

GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cLVClicK_Dummy
            ; Read index of clicked item
            $iIndex = GUICtrlRead($cLVClicK_Dummy)
            ; Determine checked state
            Local $bState = _GUICtrlListView_GetItemChecked($cLV, $iIndex)
            ; If checked and not previous checked index
            If $bState And $iIndex <> $iChecked Then
                ; Clear old checked
                _GUICtrlListView_SetItemChecked($cLV, $iChecked, False)
                $iChecked = $iIndex
                ; Set new checked
                _GUICtrlListView_SetItemChecked($cLV, $iChecked)
            ; If not checked and was previously checked
            ElseIf Not ($bState) And $iIndex = $iChecked Then
                ; Clear check
                _GUICtrlListView_SetItemChecked($cLV, $iChecked, False)
                ; Set "No check" flag
                $iChecked = -1
            EndIf
    EndSwitch
WEnd

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $iIDFrom
        Case $cLV ; It is our ListView
            Switch $iCode
                Case $NM_CLICK ; An item was clicked
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    $iIndex = DllStructGetData($tInfo, "Index")
                    ; Action the dummy control and pass the row clicked
                    GUICtrlSendToDummy($cLVClicK_Dummy, $iIndex)
                    ; Select row if only checkbox actioned
                    _GUICtrlListView_SetItemState($cLV, $iIndex, $LVIS_SELECTED, $LVIS_SELECTED)
            EndSwitch
    EndSwitch
EndFunc

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

×