Jump to content

listview and change selected item


Go to solution Solved by tomashen,

Recommended Posts

ive been searching and trying alot of samples on forum but nothing works how i want itto and i cant modify them >.< 

i am trying to create a listview with guictrlsetonevent ().. but listview isnt reacting to setonevent .. why? 

i just want when  i click on listview items that the function get called and read what item is selected  and change the text on double click 

 

i specifically looked at this for a bit of time 

but your method isnt returning anything to me ... i have 2 listviews in my gui 

Edited by tomashen

Proud of AutoIt Proud of MySelf :)

Link to comment
Share on other sites

  • Moderators

tomashen,

You will need to use a message handler - take a look at my GUIListViewEx UDF. :)

M23

Edit: I now see you linked to one of my scripts which uses a message handler. I would counsel against detecting single clicks on a ListView - quite often I have found them to be eaten by the control itself. I again point you to my UDF - it allows for item editing and most other things. :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Solution

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "GUIControl")
Func GUIControl()
    If _WinAPI_GetFocus() <> GUICtrlGetHandle($listview) Then
        Return
    Else
        $iCount = _GUICtrlListView_GetSelectedCount($listview)
        ; Are any items selected
        If $iCount Then
            $Split = StringSplit(GUICtrlRead(GUICtrlRead($listview)), "|")
            If $Split[2] = "N" Then
                _GUICtrlListView_SetItemText($listview, _GUICtrlListView_GetSelectedIndices($listview), "Y", 1)
                _GUICtrlListView_JustifyColumn($listview, _GUICtrlListView_GetSelectedIndices($listview), 2)
            ElseIf $Split[2] = "Y" Then
                _GUICtrlListView_SetItemText($listview, _GUICtrlListView_GetSelectedIndices($listview), "N", 1)
                _GUICtrlListView_JustifyColumn($listview, _GUICtrlListView_GetSelectedIndices($listview), 2)
            EndIf _GUICtrlListView_SetItemSelected($listview, -1, 0, 0)
        EndIf
    EndIf
EndFunc   ;==>GUIControl
this changes the Y=Yes / N=No values on subitem :P because this is easier for me as instead of making checkboxes :P

 

done this myself except i used a little snippet part of some source i cant remember where i found it ... my head is all over the place :D

 

but other people will know how to use this... 

 

EDIT : bah ... fix the  autoit code melba please... i try edit and edit 5 times now but everything come like that in green ... >.>

Edited by Melba23
Fixed code tags

Proud of AutoIt Proud of MySelf :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...