czardas Posted April 18, 2016 Share Posted April 18, 2016 (edited) I have a listview control containing csv data. I want to modify rows in a variety of ways. The first idea is to paste csv formatted strings, but that's too complicated for most people. I need a second method. I hate standard form design so much: enter ID, set max size, click next field. What were these designers thinking? Anyway, I came up with this. It's not a perfect, but I wanted to ask how I might improve it, or can you think of something better. expandcollapse popup#include <GuiEdit.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Local $aHeaders = ["Index","Date","Time","Event","Artist","Venue"] ; example Local $aRow = [['00','20/10/15','19.45','???','REM','Wembley']] Local $sDefault = "", $sDelim = ChrW(0x2759) ; 254F 25AF FF5C 275A 2759 For $j = 0 To UBound($aRow, 2) -2 $sDefault &= $aRow[0][$j] & $sDelim Next $sDefault &= $aRow[0][UBound($aRow, 2) -1] Local $iLastIndex = UBound($aRow, 2) -1 Local $iStyles = BitOR($WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL) Local $sLastGoodString = $sDefault Local $hGui = GUICreate('Table Row', 600, 75, -1, -1) Local $hInput = GUICtrlCreateEdit($sDefault, 10, 27, 580, 42, $iStyles) GUICtrlSetFont($hInput, 10, 400, 0, 'Verdana') Local $hLabel = GUICtrlCreateLabel("Column Header :", 10, 7, 90, 12) Local $hLabelField = GUICtrlCreateLabel($aHeaders[0], 92, 7, 60, 12) Local $aSel = [0,0] GUISetState(@SW_SHOW) _GUICtrlEdit_SetSel ($hInput, $aSel[0], $aSel[1]) Local $iMsg, $iField = 0 While $iMsg <> $GUI_EVENT_CLOSE $iMsg = GUIGetMsg() $sRead = GUICtrlRead($hInput) If Not StringInStr($sRead, $sDelim, 0, $iLastIndex) Or StringInStr($sRead, $sDelim, 0, $iLastIndex +1) Then GUICtrlSetData($hInput, $sLastGoodString) _GUICtrlEdit_SetSel ($hInput, $aSel[0], $aSel[1]) Else ; everythings going fine $sLastGoodString = $sRead $aSel = _GUICtrlEdit_GetSel ($hInput) For $i = 1 To $iLastIndex +1 $iLocation = StringInStr($sRead, $sDelim, 0, $i) If $iLocation > $aSel[0] Or $i = $iLastIndex +1 Then If $iField <> $i Then $iField = $i GUICtrlSetData($hLabelField, $aHeaders[$iField -1]) EndIf ExitLoop EndIf Next EndIf WEnd Notice that you can't delete, type or add more delimiters. Edited April 19, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
JohnOne Posted April 19, 2016 Share Posted April 19, 2016 Not certain what the goal is to be honest, but perhaps tabbing between entry "fields" for want of a better word, might be more intuitive. It's the first thing I tried. And maybe hi-lighting the entry when it is entered into. 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...
czardas Posted April 19, 2016 Author Share Posted April 19, 2016 (edited) At first I just wanted to write a single CSV line and insert it into the listview control. For that I only need a single input box. Then I thought it would be nice if I could type commas into the fields, without having to think about where to put the double quotes that are needed. The problem is that commas are already used as delimiters between fields. If I use a separate input for each field, I have to define the width of each input and try to fit them all on a GUI. In this case I'll need to code an embedded GUI with a horizontal scroll bar which might be fun to design, but not necessarily much fun for the user. What I think would be best would be to have input areas that expand as you type more characters with autoscroll enabled. However I want to paste a CSV string into the control (all fields) in one hit. There are several design considerations and this is one possible approach. I just modified it slightly, so I can try different Unicode delimiters. Don't use TAB: use Left/Right arrow keys. You mentioned highlighting - maybe a Rich edit control. It's getting more and more complicated. Also imagine you select a single row in the listview - then the delim input control is automatically updated with the row's contents, so you can edit the CSV from there. Edited April 19, 2016 by czardas operator64 ArrayWorkshop 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