darzanmihai Posted November 25, 2008 Share Posted November 25, 2008 (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 November 25, 2008 by darzanmihai I do not like stupid and idiot people that write idiot things...If you are one, do not write. Link to comment Share on other sites More sharing options...
darzanmihai Posted November 25, 2008 Author Share Posted November 25, 2008 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. Link to comment Share on other sites More sharing options...
ken82m Posted November 25, 2008 Share Posted November 25, 2008 (edited) I figured another way on that one but yours looks better i thinkI also added the icon but I couldn't find anyway to add it anywhere except the first column so I swapped em.KennyEDIT: Added return string for selected indexes and the text of those indexesexpandcollapse popup#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 November 25, 2008 by ken82m "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." Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now