l270ucas Posted August 28, 2014 Share Posted August 28, 2014 So i have searched through the forum and couldnt find my answer and i dont know which function to use. All i want to do is assign the date to the different numbers for when something is checked out. I cant figure out how to get it to read the variable from the item column and then transfer it to the same row in the date column. I have a feeling im just over looking something because it seems like it sound be pretty easy to do. thanks expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <Date.au3> Dim $arrayT[100] Dim $arrayD[100] #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 435, 242, 192, 124) $Button1 = GUICtrlCreateButton("Check In", 264, 48, 137, 41) $Button2 = GUICtrlCreateButton("Check Out", 264, 176, 137, 41) $List1 = GUICtrlCreateListView( "Item" , 20, 32, 221, 201) $Datelist = GUICtrlCreateListView("Date", 80, 32, 160, 201) For $it = 1 To UBound($arrayT) - 1 $arrayT[$it] = GUICtrlCreateListViewItem($it, $List1) Next For $id =1 To UBound($arrayD) - 1 $arrayD[$id] = GUICtrlCreateListViewItem("",$Datelist) Next GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() $ReadList = GUICtrlRead($List1) Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button2 $Gettime = _NowDate () EndSwitch WEnd Link to comment Share on other sites More sharing options...
MikahS Posted August 28, 2014 Share Posted August 28, 2014 This should do the trick: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <Date.au3> Dim $arrayT[100] Dim $arrayD[100] Local $counter = 1 ; start the counter at 1 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 435, 242, 192, 124) $Button1 = GUICtrlCreateButton("Check In", 264, 48, 137, 41) $Button2 = GUICtrlCreateButton("Check Out", 264, 176, 137, 41) $List1 = GUICtrlCreateListView( "Item" , 20, 32, 221, 201) $Datelist = GUICtrlCreateListView("Date", 80, 32, 160, 201) For $it = 1 To UBound($arrayT) - 1 $arrayT[$it] = GUICtrlCreateListViewItem($it, $List1) Next For $id =1 To UBound($arrayD) - 1 $arrayD[$id] = GUICtrlCreateListViewItem("",$Datelist) Next GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() $ReadList = GUICtrlRead($List1) Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button2 $Gettime = _NowDate () GUICtrlSetData($arrayD[$counter], $Gettime) ; we want to set the data into the listview $counter += 1 ; increment the counter variable for the arrayD EndSwitch WEnd Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 28, 2014 Moderators Share Posted August 28, 2014 @MikahS, the problem with the way you have it set up is it will automatically start at the first listview item. If I click checkout on item #10, for example, it will still put the date under item 1. And if I click the Checkout button again for whatever reason, it moves down to the next item because you are incrementing the count variable. I would do something like this, so you're always focused on whichever item you highlight. @l270ucas, the next problem you will see is the height of the columns in your listview. Once you get past your stated height of 210 (about line item 15, I believe), the dates will no longer show up. I would do something like this instead, where you're using just a single multi-column listview instead of two. It focuses only on the line item you have highlighted, and scrolls through all 100 (99) items. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <Date.au3> Local $arrayT[100] Local $arrayD[100] $Form1 = GUICreate("Form1", 435, 242, 192, 124) $Button1 = GUICtrlCreateButton("Check In", 264, 48, 137, 41) $Button2 = GUICtrlCreateButton("Check Out", 264, 176, 137, 41) $List1 = GUICtrlCreateListView( "Item" , 20, 32, 221, 201) $Datelist = _GUICtrlListView_AddColumn($List1, "Date", 50) For $it = 1 To UBound($arrayT) - 1 $arrayT[$it] = GUICtrlCreateListViewItem($it, $List1) Next For $id =1 To UBound($arrayD) - 1 $arrayD[$id] = _GUICtrlListView_AddSubItem($List1, $id - 1, "", 1, $id) Next GUISetState(@SW_SHOW) While 1 $ReadList = GUICtrlRead($List1) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button2 _getHighlightedItem() EndSwitch WEnd Func _getHighlightedItem() $Gettime = _NowDate () For $x = 0 To UBound($arrayT) - 1 $sIndex = _GUICtrlListView_GetItemSelected($List1, $x) If $sIndex = True Then _GUICtrlListView_AddSubItem($List1, $x, $Gettime, 1, $x + 1) ExitLoop EndIf Next EndFunc From this point, it would simply be another call to _GUICtrlListView_AddColumn to create a column for check-in date (territories? ), and the same logic to record those dates. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
MikahS Posted August 29, 2014 Share Posted August 29, 2014 JLogan you are quite right! Glad we have mvps like you! Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
l270ucas Posted September 2, 2014 Author Share Posted September 2, 2014 Thanks thats what i was going for @JLogan2013. And you are correct trying to figure out a way to keep the territories organized we will see how well it goes though. haha 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