faustf Posted May 20, 2013 Share Posted May 20, 2013 hi guy i have program , in this prog i want by a button open alittle listview with 2 column select one of item and put in input (in principal form ) this is a code expandcollapse popupFunc _anagrafica_tab2() $Form2 = GUICreate("Cerca in Anagrafica", 346, 267, 477, 179) $Input0 = GUICtrlCreateInput("", 16, 40, 185, 21) $List4 = GUICtrlCreateListView("Nome | ID ", 5, 74, 332, 149,$LVS_EX_GRIDLINES) _GUICtrlListView_SetExtendedListViewStyle($List4, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES)) ; questa stringa fa la griglia stile excel GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 280) ; Nome Anagrafica GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 45) ; ID Nome $Label1 = GUICtrlCreateLabel("Cerca", 16, 23, 32, 17) $Button1 = GUICtrlCreateButton("Cerca", 216, 40, 75, 21, 0) $Button2 = GUICtrlCreateButton("Inserisci", 256, 232, 75, 25, 0) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "_chiudi") _SQL_Startup() $l=0 Local $aRow, $iRows, $iCols _SQLite_GetTable2d($Db, "SELECT * FROM anagrafica;", $aRow, $iRows, $iCols) For $i = 1 To $iRows - 0 _GUICtrlListView_AddItem($List4, $arow[$i][1], $i) ;nome ditta _GUICtrlListView_AddSubItem($List4,$l, $arow[$i][0], 1, 1) ; mail $l=$l+1 Next _SQLite_Close($Db) _SQLite_Shutdown() GUICtrlSetOnEvent($Button1, "_cercaanagrafica_tab2") GUICtrlSetOnEvent($Button2, "On_Button3") EndFunc ;==>_anagrafica_tab2 Func On_Button3(); bootone inserisci anagrafica Local $test=GUICtrlRead($List4,1) MsgBox(0,'',$test) $sSelected_Data = StringTrimRight(GUICtrlRead(GUICtrlRead($List4)), 1) $string = StringSplit($sSelected_Data, "|") ;Crea un array con le lettere, ogni volta che c' è \ creo un dato $verifica = $string[1] If $sSelected_Data <> "" Then GUICtrlSetData($Input1_tab2, $verifica) EndIf GUIDelete($Form2) EndFunc ;==>On_Button3 Func _cercaanagrafica_tab2() $testodacercare = GUICtrlRead($Input0) $iI = _GUICtrlListView_FindInText($List4, $testodacercare) MsgBox(4160, "Info", "Target: " & $iI) _GUICtrlListView_EnsureVisible($List4, $iI) ;_GUICtrlListView_SetItemDropHilited($List4, $iI,True) _GUICtrlListView_SetItemFocused($List4, $iI,True) ;GUICtrlSetData($List4,$iI) EndFunc ;==>_cercaanagrafica_tab2 when i try to read $list4 not read give me always 0 Local $test=GUICtrlRead($List4,1) MsgBox(0,'',$test) Link to comment Share on other sites More sharing options...
mikell Posted May 20, 2013 Share Posted May 20, 2013 You should use ControlListView w/ "GetText" instead Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 20, 2013 Moderators Share Posted May 20, 2013 faustf, As the Help file explains, you need to use GUICtrlRead twice to get the text from a ListView - first to get the ControlID of the selected item and then again to get the content. You actually do this a few lines later in your script: $sSelected_Data = StringTrimRight(GUICtrlRead(GUICtrlRead($List4)), 1) So you need to do the same thing if you want to check the value beforehand. Furthermore, why are you using the "advanced" flag when trying to display the content? All that does for ListViewItems is to return "The state of the ListViewItem if $LVS_EX_CHECKBOXES exStyle used" as also explained in the Help file. Well worth reading it carefully when things do not seem to work as expected. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
BrewManNH Posted May 20, 2013 Share Posted May 20, 2013 How come you are using Local $test = GUICtrlRead($List4, 1) in one line but using $sSelected_Data = StringTrimRight(GUICtrlRead(GUICtrlRead($List4)), 1) in another line? Either you're using code you don't understand or you made a mistake somewhere. Because the second line will read the text of the ListView item, and the first one will read the index of it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 20, 2013 Share Posted May 20, 2013 (edited) This maybe relates to your issue as well. The On_Button3 function does not know what the variable $List4 is. You probably need to either declare it globally or pass it's value to the called function. Edited May 20, 2013 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
faustf Posted May 20, 2013 Author Share Posted May 20, 2013 yes understund melba but result of this $sSelected_Data = StringTrimRight(GUICtrlRead(GUICtrlRead($List4)), 1) is 0 :( and i don understund why Link to comment Share on other sites More sharing options...
careca Posted May 20, 2013 Share Posted May 20, 2013 Show us more code, so we can run it and see what is really going on. Alternatively, try the sugestion in the 2nd post. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe 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