Sign in to follow this  
Followers 0
darzanmihai

Need help!

3 posts in this topic

#1 ·  Posted (edited)

I have 2 questions:

1.How could I insert into a ListView, a listviewitem that contains text and icon? I supose that I have to use the $LVS_ICON style...but I don't know how.

2.How could I read the multiple sellections? using the guictrlread() I get only one value.

My code is:

#include <array.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GuiListView.au3>

#Region
$Form1 = GUICreate("Form", 633, 328, 239, 125 )
$Users = GUICtrlCreateListView("User Name|Status", 6, 8, 393, 285,$LVS_SHOWSELALWAYS)
GUICtrlSendMsg(-1, 0x101E, 0, 300)
GUICtrlSendMsg(-1, 0x101E, 1, 70)
$1=GUICtrlCreateListViewItem("Text1|ICON1",$Users)
$2=GUICtrlCreateListViewItem("Text2|ICON2",$Users)
$View = GUICtrlCreateButton("View", 406, 42, 215, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($Form1)
            ExitLoop
        Case $View
            MsgBox(0,"",GUICtrlRead(GUICtrlRead($Users)))
    ;MsgBox(0,"","not yet done")
    EndSwitch
WEnd
Edited by darzanmihai

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites



For the seccond question I found the answer:

#include <array.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GuiListView.au3>

#Region
$Form1 = GUICreate("Form", 633, 328, 239, 125 )
$Users = GUICtrlCreateListView("User Name|Status", 6, 8, 393, 285,$LVS_SHOWSELALWAYS)
GUICtrlSendMsg(-1, 0x101E, 0, 300)
GUICtrlSendMsg(-1, 0x101E, 1, 70)
Dim $x[101][2]
For $i = 0 to 100
$x[$i][0]=$i
$x[$i][1]=GUICtrlCreateListViewItem("Text"&$i+1&"|ICON"&$i+1,$Users)
Next
$View = GUICtrlCreateButton("View", 406, 42, 215, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($Form1)
            ExitLoop
        Case $View
            $a = ControlListView ( "Form", "", $Users, "GetSelected" ,1)
            $Selected = StringSplit($a,"|")
            For $i=1 to $Selected[0]
                MsgBox(0,$Selected[$i]&" - "&$x[$i-1][1],GUICtrlRead($x[$Selected[$i]][1]))
            Next
    EndSwitch
WEnd

But how could I insert icons into Listview?


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I figured another way on that one but yours looks better i think

I also added the icon but I couldn't find anyway to add it anywhere except the first column so I swapped em.

Kenny

EDIT: Added return string for selected indexes and the text of those indexes

#include <array.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#Include <GuiListBox.au3>

#Region
$Form1 = GUICreate("Form", 633, 328, 239, 125 )
$Users = GUICtrlCreateListView("Status|User Name", 6, 8, 393, 285, $LVS_SHOWSELALWAYS)
GUICtrlSendMsg(-1, 0x101E, 0, 70)
GUICtrlSendMsg(-1, 0x101E, 1, 300)
$0=GUICtrlCreateListViewItem("|Text1",$Users)
GUICtrlSetImage(-1, "test.ico")
$1=GUICtrlCreateListViewItem("|Text2",$Users)
GUICtrlSetImage(-1, "test.ico")
$View = GUICtrlCreateButton("View", 406, 42, 215, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($Form1)
            ExitLoop
        Case $View
            $Sel = _GUICtrlListView_GetSelectedIndices($Users, True)
            _ArrayDelete($sel, 0)
            $SelText = ""
            For $i = 0 To UBound($Sel) - 1
                $SelText = $SelText  & _GUICtrlListView_GetItemText($Users, $Sel[$i], 1) & "|" & $SelText
            Next
            $SelText = StringTrimRight($SelText, 1)
            $Sel = _ArrayToString($Sel)

                                                    ;Both will be null if nothing is selected
            MsgBox(0, "Indexes" , $Sel)
            MsgBox(0, "Text" , $SelText)
    EndSwitch
WEnd
Edited by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

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