Garp99HasSpoken Posted February 14, 2013 Share Posted February 14, 2013 I have a form entry "Add customer" which I want to allow the ability to enter many customers until they Cancel or "X" out of screen. After entering the first customer, I reset all form values to defaults and the form stays out front. However the old values are still shown on the form. How do I do a refresh of the form with the new values? Do I have to call each individual field with a specific GUICtrlSetData() or is it better practice to destroy the form and call the CreateForm to init the values and re-create the form? Any examples to look at? Also, I need to understand how to update the Customer TAB with a ListView of customers entered. Please point me in the right direction with an example. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 Garp99HasSpoken,If you store the ControlIDs of the various inputs in an array, then clearing them is just a simple loop around a GUICtrlSetData line. As to your second question, I assume you have a listview somewhere, so just add the content of the "customer name" input to the listview before you clear it. 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...
Garp99HasSpoken Posted February 15, 2013 Author Share Posted February 15, 2013 I agree that using an array is always simpler but not easier from an understanding of the code if you son't readily know what key 3 or 21 is. Which means L_LABELS for each when needed. It's a different approach than having a variable for each field. In the end I just decided to create a function to set all the values, so it could be re-used elsewhere. Question about question etiquette on the forum: Should I start a new thread for *each* problem I run into / need help with, so that others can find it via search, or is it ok to just start a thread about my project and ask the problems as they occur, this way those that follow it will better understand what I am working on and the problems I am running into -- in my first AutoIt GUI. Link to comment Share on other sites More sharing options...
BrewManNH Posted February 15, 2013 Share Posted February 15, 2013 One method of making your array elements easier to reference is to use Enum with the names of the controls you want in each position. #include <GUIConstantsEx.au3> Example() Func Example() Local $msg Local Enum $Run, $ButtonTest Local $aHandles[2] GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $aHandles[$Run] = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $aHandles[$ButtonTest] = GUICtrlCreateButton("Button Test", 0, -1) GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $aHandles[$Run] Run('notepad.exe') ; Will Run/Open Notepad Case $msg = $aHandles[$ButtonTest] MsgBox(4096, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed EndSelect WEnd EndFunc 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...
Moderators Melba23 Posted February 15, 2013 Moderators Share Posted February 15, 2013 Garp99HasSpoken,I am not sure I agree with you there. You could always have the array as well as the normal variables - then you can use whichever is best suited to the requirement. And if you structure your code you might well be able to use a Local array and so not waste resources. Or you could use an "associative array" so that you can use descriptive names - my personal favourite is here. I use it often when I have controls that I need to reference within another function - just pass the whole array rather than a whole list of variables - and I can still use the descriptive names. An example: ; Create checkboxes AssocArrayAssign($aParam_List, "GUI", GUICtrlCreateCheckbox(" GUI visible", 10, 95)) AssocArrayAssign($aParam_List, "Status", GUICtrlCreateCheckbox(" Statusbar", 10, 125)) AssocArrayAssign($aParam_List, "Taskbar", GUICtrlCreateCheckbox(" Taskbar Button", 10, 155)) AssocArrayAssign($aParam_List, "Scroll", GUICtrlCreateCheckbox(" Details Scroll", 10, 185)) AssocArrayAssign($aParam_List, "Drop", GUICtrlCreateCheckbox(" Drop accept", 10, 215))I would suggest opening a new thread for each problem, unless they are very closely related. People normally only read the first few posts unless they are already involved personally in the thread - so if you change tack once well into a thread you might not get the correct people reading about the new problem. So start a new thread, correctly titled, and attract those who know about that particular aspect of AutoIt. 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...
Garp99HasSpoken Posted February 15, 2013 Author Share Posted February 15, 2013 OK, 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