marcsusy Posted October 13, 2012 Share Posted October 13, 2012 Hello I created a GUI with step GUICtrlCreateListView and values from a database, when you step values GUICtrlCreateListViewItem the first time works fine, but when I try to update the values that have changed again with the same function GUICtrlCreateListViewItem values are not updated still shows the previous, only works if I delete the window and return to create it, as I can do so without having to clear the main GUI. Who can help me? Link to comment Share on other sites More sharing options...
StringingLong Posted October 14, 2012 Share Posted October 14, 2012 Take this example to get the basics down. Play with it first. Then, notice that as new items are added, the listview is automatically refreshed to reflect the current state. You likely are doing something wrong in the updating from database to listview. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> $hWndMain = GUICreate("List View Example", 420, 460) $hListView = _GUICtrlListView_Create($hWndMain,"Items", 20, 20, 380,380) $labelNumItems = GuiCtrlCreateLabel("Number of items: ",2,2,160,20) $btnAddItem = GUICtrlCreateButton("Add an item", 20,420,120,30) $btnRemoveItem = GUICtrlCreateButton("Remove an item", 160,420,120,30) _GUICtrlListView_AddItem($hListView, "Item 1", 0) _GUICtrlListView_AddItem($hListView, "Item 2", 1) _GUICtrlListView_AddItem($hListView, "Item 3", 2) _GUICtrlListView_SetColumnWidth($hListView,0,380) $numItems = _GUICtrlListView_GetItemCount($hListView) GuiCtrlSetData($labelNumItems, "Number of items: " & $numItems) GuiSetState(@SW_SHOW,$hWndMain) While 1 $msg = GUIGetMsg() switch($msg) case $GUI_EVENT_CLOSE Exit case $btnAddItem $itemString = "New Item " & random(1,99999,true) _GUICtrlListView_AddItem($hListView, $itemString, $numItems) $numItems = _GUICtrlListView_GetItemCount($hListView) GuiCtrlSetData($labelNumItems, "Number of items: " & $numItems) case $btnRemoveItem $aItemsSelected = _GUICtrlListView_GetSelectedIndices($hListView,True) $numSelected = $aItemsSelected[0] for $i=1 to $numSelected _GUICtrlListView_DeleteItem($hListView,$aItemsSelected[$i]) next $numItems = _GUICtrlListView_GetItemCount($hListView) GuiCtrlSetData($labelNumItems, "Number of items: " & $numItems) EndSwitch WEnd GUIDelete($hWndMain) Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 14, 2012 Share Posted October 14, 2012 posting the script could help you get the mistake you are making. My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
AutoBert Posted October 15, 2012 Share Posted October 15, 2012 A small Eample how to edit an Item: #include #include $hWndMain = GUICreate("List View Example", 420, 460) $ListView = GUICtrlCreateListView("Col1|Col2|Col3", 2, 25, 416, 380) $labelNumItems = GUICtrlCreateLabel("Number of items: ", 2, 2, 160, 20) $btnEditItem = GUICtrlCreateButton("Edit an item", 20, 420, 380, 30) For $i = 0 To 19 GUICtrlCreateListViewItem("Item " & $i & "|Col" & $i & ".1|Col " & $i & ".2", $ListView) Next _GUICtrlListView_SetColumnWidth($ListView,0,80) _GUICtrlListView_SetColumnWidth($ListView,1,180) _GUICtrlListView_SetColumnWidth($ListView,2,120) $numItems = _GUICtrlListView_GetItemCount($ListView) GUICtrlSetData($labelNumItems, "Number of items: " & $numItems) GUISetState(@SW_SHOW, $hWndMain) While 1 $msg = GUIGetMsg() Switch ($msg) Case $GUI_EVENT_CLOSE Exit Case $btnEditItem $aItemsSelected = _GUICtrlListView_GetSelectedIndices($ListView,True) _GUICtrlListView_SetItem($ListView,"Edited Item" & $aItemsSelected[1],$aItemsSelected[1]) _GUICtrlListView_SetItem($ListView,"Edited Col " & $aItemsSelected[1]& ".1",$aItemsSelected[1],1) _GUICtrlListView_SetItem($ListView,"Edited Col " & $aItemsSelected[1]& ".2",$aItemsSelected[1],2) EndSwitch WEnd GUIDelete($hWndMain) 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