John117 Posted July 29, 2007 Share Posted July 29, 2007 (edited) I have a gui that queries a database for previous selections before load. All input boxes are updating and retaining correctly. Checkbox selections are not. Here is what have tried. When a Checkbox is checked, its GUICtrlRead is 1, if not it is 4 I am saving the value of the checkbox to a database: $sExec = "UPDATE Users SET Eleven='" & GUICtrlRead($Checkbox1) & "' WHERE User_Name='" & $UserName & "'" ; Change a record If _SQLite_Exec($hDB, $sExec) = $SQLITE_OK Then ConsoleWrite("Debug: Successfully updated a record." & @LF) This is working. It is storing 1 or 4 correctly depending on if the box was checked or not. The next time I load it should set the box to 1 or 4 from that database save, but it is actually renaming the checkbox and not checking/unchecking it GUICtrlSetData($Checkbox1, $aRow[10]) Anyone have any idea what's going on here? simple value test below to show 1 and 4 CODE#include <GUIConstants.au3> $Form1 = GUICreate("Update Profile", 780, 380) $UpdateProfileButton = GUICtrlCreateButton("Update", 700, 350, 75, 25, 0) $checkCN = GUICtrlCreateCheckbox("CHECKBOX 1", 10, 10, 120, 20) GUISetState() ; will display an dialog box with 1 checkbox ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $UpdateProfileButton Then MsgBox(64, "Results", GUICtrlRead($checkCN)) EndIf WEnd Edited July 29, 2007 by Hatcheda Link to comment Share on other sites More sharing options...
Paulie Posted July 29, 2007 Share Posted July 29, 2007 I believe you missed the GuiCtrlSetState Function If $aRow[10] = 1 then GuiCtrlSetState($Checkbox1, $GUI_CHECKED) ElseIf $aRow[10] = 4 then GuiCtrlSetState($Checkbox1, $GUI_UNCHECKED) EndIf I think something like that should suit your needs Link to comment Share on other sites More sharing options...
John117 Posted July 29, 2007 Author Share Posted July 29, 2007 Thanks! I can adapt that! Link to comment Share on other sites More sharing options...
Paulie Posted July 29, 2007 Share Posted July 29, 2007 No problem, hope it works out for you Link to comment Share on other sites More sharing options...
John117 Posted July 29, 2007 Author Share Posted July 29, 2007 Hey it worked out well! I reduced the code to: If $aRow[10] = 1 then GuiCtrlSetState($Checkbox1, $GUI_CHECKED) Since 4 is the default load value (Unchecked) I didn't need it 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