Jump to content

Recommended Posts

Posted (edited)

I would like to disable button (make it gray) when none of indices are selected from ListView. Any idea?

 

my code:

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
$gui = GUICreate("mygui", 200,200)
$idListview = GUICtrlCreateListView("Name|Surname", 10, 10, 180, 100)
GUICtrlCreateListViewItem("John|Oconnor", $idListview)
GUICtrlCreateListViewItem("Ken|Block", $idListview)
$button = GUICtrlCreateButton("Button", 50, 120, 100, 50)
GUISetState(@SW_SHOW, $gui)
While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
       Case $GUI_EVENT_CLOSE
           Exit
   EndSwitch
WEnd
Edited by maniootek
Posted (edited)

Cześć / Hi.

Please use code tags.

Read "How to post code on the forum"

EDIT:

and Tidy your code.

Edited by mLipok

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

something like this?

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
$gui = GUICreate("mygui", 200, 200)
$idListview = GUICtrlCreateListView("Name|Surname", 10, 10, 180, 100)
$h_idListview = ControlGetHandle($gui, '', $idListview)
$iSelectedCount = 0
$iLastSelectedCount = 0
GUICtrlCreateListViewItem("John|Oconnor", $idListview)
GUICtrlCreateListViewItem("Ken|Block", $idListview)
$button = GUICtrlCreateButton("Button", 50, 120, 100, 50)
GUISetState(@SW_SHOW, $gui)

GUICtrlSetState($button, $GUI_DISABLE)
While 1
    $nMsg = GUIGetMsg()
    $iSelectedCount = _GUICtrlListView_GetSelectedCount($h_idListview)

    If $iLastSelectedCount <> $iSelectedCount Then
        If $iSelectedCount Then
            GUICtrlSetState($button, $GUI_ENABLE)
        Else
            GUICtrlSetState($button, $GUI_DISABLE)
        EndIf
        $iLastSelectedCount = $iSelectedCount
    EndIf

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

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

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