maba Posted February 4, 2012 Share Posted February 4, 2012 Hi all, the simplest (and rightest) way to have only one form to insert or modify data? Example:I would manage sqlite data with one form for the two operation with simple IFs to load data, enable or disable fileds, etc. Put all code in a function that accepts an argument like the record ID? Thanks Link to comment Share on other sites More sharing options...
Mikeman27294 Posted February 4, 2012 Share Posted February 4, 2012 (edited) Yes, that is definately simple. Assuming that you would use an editbox for changing your data: Global $GUI, $Edit, $File, $New, $Open, $Save, $msg, $File, $FileContents $GUI = GUICreate("Example",500,500) $Edit = GUICtrlCreateEdit("", 0, 0, 500, 470) $File = GUICtrlCreateMenu("File") $New = GUICtrlCreateMenuItem("&New", $File) $Open = GUICtrlCreateMenuItem("&Open", $File) $Save = GUICtrlCreateMenuItem("&Save", $File) GUISetState(@SW_SHOW, $GUI) While 1 $msg = GUIGetMsg() Switch $msg Case -3;GuiMsg -3 = $GUI_EVENT_EXIT Exit Case $New GUICtrlSetData($Edit, "");Sets the data in the editbox to nothing Case $Open $File = FileOpenDialog("Open", @DesktopDir, "All Files (*.*)");Allows you to select the desired file $FileContents = FileRead($File);Sets the value of $FileContents to the text read from the file GUICtrlSetData($Edit, $FileContents);Sets the data in the editbox to the data in $FileContents Case $Save $FileContents = GUICtrlRead($Edit);Sets the value of $FileContents to the text read from the edit box FileWrite($File, $FileContents);Writes the value of $FileContents to the file EndSwitch WEnd There you go, I hope that's what you were looking for. The commands you want to look are are FileOpenDialog, FileRead, GuiCtrlSetData, GuiCtrlRead and FileWrite. Unfrotunately, I don't know much about SQLite so I cannot help much there without more information, but the code provided should start you off. Edited February 4, 2012 by Mikeman27294 Link to comment Share on other sites More sharing options...
maba Posted February 4, 2012 Author Share Posted February 4, 2012 (edited) Thanks for your quickly answer!We can use this example: New Contact and Edit Contact button opens two different form with the same input fields.I have a similar form with about 30 fields.Should I use GUICtrlSetData in the while loop for each field or I can use IF statement in a function that create the form and after call (e.g.)_CreateNewOrEditForm from "New Contact" and "Edit Contact" buttons? Edited February 4, 2012 by maba Link to comment Share on other sites More sharing options...
maba Posted February 27, 2012 Author Share Posted February 27, 2012 Any ideas or suggestions? Is it a wrong things? Thanks 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