JohnOne Posted March 26, 2015 Share Posted March 26, 2015 (edited) I get a list externally and create a load of labels and input fields to match it. If that list is larger than the gui can handle, the controls are outside the bounds of the gui height. Wondering what sort of control I can put them in, so user can scroll to see all the fields. Some sort of scrollable panel would be ace, but open to any suggestions. Here is reproducer. expandcollapse popup#include <Array.au3> Global $AppName = "The App" Global $aProducts = FileReadToArray(@ScriptDir & "\Products.txt") ;_ArrayDisplay($aProducts) _AbsentCategory($aProducts) Func _AbsentCategory(ByRef $array) If UBound($array) < 1 Then Return EndIf $Top = 40 Local $aControls[UBound($array)][4] Local $hNotFoundGUI = GUICreate($AppName & ": Products need adding", 575, 700) ; Labels GUICtrlCreateLabel("Product name", 15, 10, 100) GUICtrlCreateLabel("Category 1", 240, 10, 100) GUICtrlCreateLabel("Category 2", 410, 10, 100) Local $hNotFounButtonOK = GUICtrlCreateButton("Done", 15, 670, 60) ; Create an array of contrils with the backup array as text For $y = 0 To UBound($array) - 1 GUICtrlCreateLabel($array[$y], 15, $Top, 210, 20) $aControls[$y][0] = GUICtrlCreateInput("", 240, $Top, 150) ; cat 1 $aControls[$y][1] = GUICtrlCreateInput("", 410, $Top, 150) ; cat 2 $Top += 30 Next GUISetState() Sleep(5000) While GUIGetMsg() <> $hNotFounButtonOK WEnd ; Not finished yet ; Check all fields are filled before proceding Do Until _Checkfields($aControls) ; Update array For $i = 0 To UBound($array) - 1 $array[$i][1] = GUICtrlRead($aControls[$i][0]) $array[$i][2] = GUICtrlRead($aControls[$i][1]) Next EndFunc ;==>_AbsentCategory Func _Checkfields(ByRef $array) For $i = 0 To UBound($array) - 1 If GUICtrlRead($array[$i][0]) = "" Or GUICtrlRead($array[$i][1]) = "" Then MsgBox(4096 + 48, $AppName & ": - Warning", "Fill all fields" & @CRLF & "and press OK") Return 0 EndIf Next Return 1 EndFunc ;==>_Checkfields Here is Products.txt Product1 Product2 Product3 Product4 Product5 Product6 Product7 Product8 Product9 Product10 Product11 Product12 Product13 Product14 Product15 Product16 Product17 Product18 Product19 Product20 Product21 Product22 Product23 Product24 Product25 Product26 Product27 Product28 Product29 Edited March 26, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jdelaney Posted March 26, 2015 Share Posted March 26, 2015 (edited) Maybe overly complicated, but you can create a listview and only one edit and label...make the label and edit disabled until a listview item is selected...populate the label, and allow user to add data to the edit...add a button to submit the number to the listview, update the listview, and clear out the edit and label plus make disabled again. Edited March 26, 2015 by jdelaney JohnOne 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
JohnOne Posted March 26, 2015 Author Share Posted March 26, 2015 Thanks for the suggestion, I've had my fill of working with listview for now, though. I will use as a last resort if I or someone else cannot come up with a more simple solution. Cheers. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted March 26, 2015 Moderators Solution Share Posted March 26, 2015 JohnOne,Look at my Scrollbars UDF - GUIScrollbars_Size_Example_2 shows you how to do what you want. M23 JohnOne 1 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...
JohnOne Posted March 26, 2015 Author Share Posted March 26, 2015 Sweet, cheers M23. way simpler than Listview..... On the outside expandcollapse popup#include <Array.au3> #include <GUIScrollbars_Ex.au3> Global $AppName = "The App" Global $aProducts = FileReadToArray(@ScriptDir & "\Products.txt") ;_ArrayDisplay($aProducts) _AbsentCategory($aProducts) Func _AbsentCategory(ByRef $array) If UBound($array) < 1 Then Return EndIf $Top = 40 Local $aControls[UBound($array)][4] Local $hNotFoundGUI = GUICreate($AppName & ": Products without categories", 575, 700) ; Labels GUICtrlCreateLabel("Product name", 15, 10, 100) GUICtrlCreateLabel("Category 1", 240, 10, 100) GUICtrlCreateLabel("Category 2", 410, 10, 100) ;Local $hNotFounButtonOK = GUICtrlCreateButton("Done", 15, 670, 60) ; Create an array of contrils with the backup array as text For $y = 0 To UBound($array) - 1 GUICtrlCreateLabel($array[$y], 15, $Top, 210, 20) $aControls[$y][0] = GUICtrlCreateInput("", 240, $Top, 150) ; cat 1 $aControls[$y][1] = GUICtrlCreateInput("", 410, $Top, 150) ; cat 2 $Top += 30 Next Local $hNotFounButtonOK = GUICtrlCreateButton("Done", 15, $Top - 5, 60) _GUIScrollbars_Generate($hNotFoundGUI, 570, $Top + 10) GUISetState() Sleep(5000) While GUIGetMsg() <> $hNotFounButtonOK WEnd ; Not finished yet ; Check all fields are filled before proceding Do Until _Checkfields($aControls) ; Update array For $i = 0 To UBound($array) - 1 $array[$i][1] = GUICtrlRead($aControls[$i][0]) $array[$i][2] = GUICtrlRead($aControls[$i][1]) Next EndFunc ;==>_AbsentCategory Func _Checkfields(ByRef $array) For $i = 0 To UBound($array) - 1 If GUICtrlRead($array[$i][0]) = "" Or GUICtrlRead($array[$i][1]) = "" Then MsgBox(4096 + 48, $AppName & ": - Warning", "Fill all fields" & @CRLF & "and press OK") Return 0 EndIf Next Return 1 EndFunc ;==>_Checkfields AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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