Queener Posted July 24, 2016 Share Posted July 24, 2016 I created 3 function: 1 - Search Function 2 - Load funtion (load Section names on combobox) 3 - delete function when I delete a section name, it delete and then reload section names. It does delete it, but when the load function reload the section names, the name still appear in the combobox. Checked on the ini file; it's gone. The only way it will load the changes is if I close the program then re-open it. Is there a way to update the list live in gui? Not sure if that make any sense... Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
AutoBert Posted July 24, 2016 Share Posted July 24, 2016 This is possible show script, i think you have forgotten something: reread of sectionnames (IniReadSectionNames) Link to comment Share on other sites More sharing options...
Queener Posted July 25, 2016 Author Share Posted July 25, 2016 expandcollapse popup; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ; #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> #include <EditConstants.au3> #include <ListBoxConstants.au3> #include <ComboConstants.au3> #include <Array.au3> #include <GuiComboBox.au3> $title = "Perfect Tool" $load = GUICreate($title,278,351,-1,-1,-1,-1) $inputList = GUICtrlCreateCombo("",18,72,239,28,-1,-1) GUICtrlSetFont(-1,12,400,0,"MS Sans Serif") $LConfig = GUICtrlCreatelist("",18,122,239,175,-1,$WS_EX_CLIENTEDGE) $inputSearch = GUICtrlCreateInput("",18,24,159,29,-1,$WS_EX_CLIENTEDGE) GUICtrlSetFont(-1,12,400,0,"MS Sans Serif") $bSearch = GUICtrlCreateButton("Search",184,24,73,29,-1,-1) GUICtrlSetFont(-1,12,400,0,"MS Sans Serif") $bdel = GUICtrlCreateButton("Delete",18,308,100,30,-1,-1) GUICtrlSetFont(-1,12,400,0,"MS Sans Serif") $badd = GUICtrlCreateButton("Add",157,308,100,30,-1,-1) GUICtrlSetFont(-1,12,400,0,"MS Sans Serif") GUISetState(@SW_SHOW,$load) ;Ini Top Variables $iniLoc = @ScriptDir & "\config.ini" ;List the Section Names on Seach combobox $iniLoadSearchName = IniReadSectionNames($iniLoc) $listname = "" If Not @error Then For $i = 1 To $iniLoadSearchName[0] $listname &= $iniLoadSearchName[$i] & "|" Next $inistring = StringTrimRight($listname, 1) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $bSearch GUICtrlSetData($inputlist, "") GUICtrlSetData($inputList,$inistring) Case $bdel IniDelete($iniLoc, GUICtrlRead($inputList)) GUICtrlSetData($inputlist, "") reload() EndSwitch WEnd Func Reload() GUICtrlSetData($inputList,$inistring) EndFunc Func _Check($sName = 1) ;Function to load list guictrlsetdata($InputSearch,'') guictrlsetdata($inputList,'') local $hit = false for $1 = 1 to $iniLoadSearchName[0] if stringregexp($iniLoadSearchName[$1],'(?i)\Q' & $sName & '\E') then guictrlsetdata($inputList,$iniLoadSearchName[$1]) $hit = True EndIf next if $hit Then _GUICtrlComboBox_SetCurSel ( $inputList , 0 ) ; set edit box to 1st in list ;guictrlsetdata($inputid,'ID = ' & inireadsection($inifile,guictrlread($inputsearch2))[1][1]) ; populate ID field EndIf Return EndFunc Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Queener Posted July 25, 2016 Author Share Posted July 25, 2016 [John] ID=1 Computer=HI0900 Desc=Cad Design [Kath] ID=2 Computer=HI0901 Desc=Cad Design [Ron] ID=3 Computer=HI0902 Desc=Cad Design [DelMe1] ID=1 Computer=HI0900 Desc=Cad Design [DelMe2] ID=1 Computer=HI0900 Desc=Cad Design [DelMe3] ID=1 Computer=HI0900 Desc=Cad Design [DelMe4] ID=1 Computer=HI0900 Desc=Cad Design Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
kylomas Posted July 25, 2016 Share Posted July 25, 2016 (edited) Where do you remove the deleted entry frim $inistring?. Doing this on a smart phone so may have missed it. Kylomas edit: additional info Why not operate directly on the listbox instead of reloading from the source string. See _GUICtrlListBox_DeleteString and _GUICtrlListBox_GetCurSel. If this is a multiple select listbox then you can use _GUICtrlListBox_GetSelItems to iterate through deleted items. Other alternatives include rebuilding from the altered INI file (after your delete) or altering $inistring. Hope this helps, kylomas Edited July 25, 2016 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Queener Posted July 25, 2016 Author Share Posted July 25, 2016 (edited) tried: If Not @error Then For $i = 1 To $iniLoadSearchName[0] If GUICtrlRead($inputlist) = $iniLoadSearchName[$i] Then $inistring = IniDelete($iniLoc, GUICtrlRead($inputList)) GUICtrlSetData($inputlist, "") EndIf Next GUICtrlSetData($inputList,$inistring) EndIf Still a no go... EDIT: Got it... took me awhile to figure this out... LoL ;reload the list correctly $inistring = StringReplace($inistring, "|" & GUICtrlRead($inputlist), "") ;ini delete time IniDelete($iniLoc, GUICtrlRead($inputlist)) ;clear the data GUICtrlSetData($inputlist, "") ;re-populate the list GUICtrlSetData($inputlist, $inistring) Edited July 25, 2016 by Queener Solved Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") 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