Sign in to follow this  
Followers 0
jerem488

Choose column of checkboxes in a listview

11 posts in this topic

Hi everybody,

I would like know how make to choose the column of checkboxes in a listview. I have 5 columns, and i want checkboxes in the fourth and fifth column. And only a column of two can be check. And I don't know how to do this...

Thanks


Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Share this post


Link to post
Share on other sites



Hi everybody,

I would like know how make to choose the column of checkboxes in a listview. I have 5 columns, and i want checkboxes in the fourth and fifth column. And only a column of two can be check. And I don't know how to do this...

Thanks

You'll have to monitor the checkbox status and do clean up (clear the other checkbox on the same item) when the item is selected.

Have you already coded a working GUI with the items/colums/checkbox arrangement?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You'll have to monitor the checkbox status and do clean up (clear the other checkbox on the same item) when the item is selected.

Have you already coded a working GUI with the items/colums/checkbox arrangement?

:)

Yes, I have already coded a working GUI with the items and columns.


Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Share this post


Link to post
Share on other sites

But how do I to add checkboxes in the fourth AND fifth columns ??


Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yes, I have already coded a working GUI with the items and columns.

But how do I to add checkboxes in the fourth AND fifth columns ??

I don't think you do. There is only one checkbox for the item (row), not one for each subitem (column). Have you seen any examples of a listview with subitem checkboxes? Maybe it was an owner-drawn custom control or a grid control.

:)

P.S. You can put images on subitems. By using four images (enabled-unchecked, enabled-checked, disabled-unchecked, and disabled-checked) you could simulate a checkbox with your own handling.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

This demo uses images of colored blocks in place of the various checkbox states, because I'm too lazy to go find the correct images. But it demonstrates the technique:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>

Global $hGUI, $hImage, $hListView, $iItem, $iSubItem, $sMsg, $iImage

; Create image list
$hImage = _GUIImageList_Create()
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xF0F0F0, 16, 16)) ; 0 Light Gray = disabled-unchecked
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xA0A0A0, 16, 16)) ; 1 Dark Gray = disabled-checked
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16)) ; 2 Red = enabled-unchecked
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) ; 3 Green = enabled-checked
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFFFFFF, 16, 16)) ; 4 White = Hidden checkbox

; Create GUI
$hGUI = GUICreate("ListView SubItem Checkbox Simulation", 544, 300)

; Create listview
$hListView = GUICtrlCreateListView("", 20, 20, 504, 260)
_GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_SUBITEMIMAGES, $LVS_EX_SUBITEMIMAGES)
_GUICtrlListView_SetImageList($hListView, $hImage, 1)

; Add columns
For $iSubItem = 0 To 4
    _GUICtrlListView_AddColumn($hListView, "Col " & $iSubItem, 100)
Next

; Add items
For $iItem = 0 To 4
    _GUICtrlListView_AddItem($hListView, "Row " & $iItem & ": Col 1", 4)
    For $iSubItem = 0 To 4
        _GUICtrlListView_AddSubItem($hListView, $iItem, "Row " & $iItem & ": Col " & $iSubItem, $iSubItem)
        If $iSubItem < 3 Then
            _GUICtrlListView_SetItemImage($hListView, $iItem, 4, $iSubItem) ; No checkbox
        Else
            _GUICtrlListView_SetItemImage($hListView, $iItem, $iItem, $iSubItem) ; Various checkboxes
        EndIf
    Next
Next

; Display GUI
GUISetState()

; Test column 3 of each item for checkbox status
;   Bit 0 = checked
;   Bit 1 = enabled
;   Bit 2 = hidden
For $iItem = 0 To _GUICtrlListView_GetItemCount($hListView) - 1
    $sMsg = "Row " & $iItem & ": Col 3: Checkbox is "
    $iImage = _GUICtrlListView_GetItemImage($hListView, $iItem, 3)
    If BitAND($iImage, 0x4) Then
        $sMsg &= "hidden."
    Else
        If BitAND($iImage, 0x2) Then
            $sMsg &= "enabled and "
        Else
            $sMsg &= "disabled and "
        EndIf
        If BitAND($iImage, 0x1) Then
            $sMsg &= "checked."
        Else
            $sMsg &= "unchecked."
        EndIf
    EndIf
    ConsoleWrite($sMsg & @LF)
Next

; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

....Have you seen any examples of a listview with subitem checkboxes?

Yes :)EIPListView by eltorro.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Yes :)EIPListView by eltorro.

If I'm reading that right, it just floats a child GUI over the parent ListView. I don't think that will work well with checkboxes, especially with multiple checkboxes.

For example, vertically scroll the list view while the progress bar in the demo is running. Imagine that effect with a bunch of checkboxes floating over it.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

If I'm reading that right, it just floats a child GUI over the parent ListView. I don't think that will work well with checkboxes, especially with multiple checkboxes.

For example, vertically scroll the list view while the progress bar in the demo is running. Imagine that effect with a bunch of checkboxes floating over it.

:)

Ah yes you're right, the checkboxes aren't actually part of the ListView; I'd forgotten that.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Try adapting this ownerdrawn listview with checkboxes by rasim.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Try adapting this ownerdrawn listview with checkboxes by rasim.

I think that's a more complicated version of what I already proposed. It draws the graphics CheckOn.bmp or CheckOff.bmp using complicated _GDIPlus_* functions directly. I think _GuiCtrlListView_SetItemImage() is much easier to use than all that (or at least buries the complications in an existing UDF).

The part that registers WM_NOTIFY to detect when a subitem is clicked, and then changes the graphic to represent the changed state of the "checkbox" is good, but again the drawing is over complicated when _GuiCtrlListView_SetItemImage() is available.

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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