Sign in to follow this  
Followers 0
Damein

How to deselect an item in a List?

5 posts in this topic

#1 ·  Posted (edited)

So I have two list's side by side and I am trying to make it so you can only select one item on each list. I have it setup like this:

$FavoriteListOnline = GuiCtrlCreateList("", 20,120,200,350)
    GUICtrlSetOnEvent(-1, "_OnlineSelected")
    $FavoriteListOffline = GuiCtrlCreateList("", 230,120,200,350)
    GUICtrlSetOnEvent(-1, "_OfflineSelected")

So I have a func that I want to run (_OnlineSelected or vice versa for offline) each time someone selects an item. And if that item is in a different List I want the other list deselected. Just not quite sure the command I need to send for this to happen ^^;

Thanks!

Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites



Damein,

The only way I know is to reset the list data:

#include <GUIConstantsEx.au3>

$sData = "|Line 1|Line 2|Line 3|Line 4|Line 5"

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

$cList1 = GUICtrlCreateList("", 20, 120, 200, 350)
GUICtrlSetData($cList1, $sData)
$cList2 = GUICtrlCreateList("", 230, 120, 200, 350)
GUICtrlSetData($cList2, $sData)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cList1
            GUICtrlSetData($cList2, $sData)
        Case $cList2
            GUICtrlSetData($cList1, $sData)
    EndSwitch
WEnd
Any use? :huh:

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

A little dirty, but it will do unless someone has a better way.

Sadly, each time I reset the list I need to do a check using InetRead but it's only about 1 line of text its reading so its not a large data transfer. But we'll see. Thanks!


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites

You can do this with _GUICtrlListBox_SetCurSel($hWnd, $iIndex)

If you set $iIndex to -1 it removes the selection.

Share this post


Link to post
Share on other sites

T0M50N,

Excellent! :thumbsup:

And just to prove it: ;)

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

$sData = "|Line 1|Line 2|Line 3|Line 4|Line 5"

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

$cList1 = GUICtrlCreateList("", 20, 120, 200, 350)
GUICtrlSetData($cList1, $sData)
$cList2 = GUICtrlCreateList("", 230, 120, 200, 350)
GUICtrlSetData($cList2, $sData)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cList1
            _GUICtrlListBox_SetCurSel($cList2, -1)
        Case $cList2
            _GUICtrlListBox_SetCurSel($cList1, -1)
    EndSwitch
WEnd
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