Juno_okyo

GUI ListView Example

Dec 9th, 2014
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.18 KB | None | 0 0
  1. #region
  2. #AutoIt3Wrapper_UseUpx=Y
  3. #AutoIt3Wrapper_Compression=4
  4. #AutoIt3Wrapper_Icon=E:\wamp\www\favicon.ico
  5. #AutoIt3Wrapper_Res_Comment=Coded by Juno_okyo
  6. #AutoIt3Wrapper_Res_Description=Coded by Juno_okyo
  7. #AutoIt3Wrapper_Res_Fileversion=1.0.0.0
  8. #AutoIt3Wrapper_Res_LegalCopyright=(c) 2014 by Juno_okyo's Blog
  9. #AutoIt3Wrapper_Res_Field=ProductName|Juno_okyo's Production
  10. #AutoIt3Wrapper_Res_Field=ProductVersion|1.0.0.0
  11. #AutoIt3Wrapper_Res_Field=CompanyName|J2TeaM
  12. #AutoIt3Wrapper_Res_SaveSource=N
  13. #endregion
  14.  
  15. ; Includes
  16. #include <Misc.au3>
  17. #include <ButtonConstants.au3>
  18. #include <GUIConstantsEx.au3>
  19. #include <ListViewConstants.au3>
  20. #include <WindowsConstants.au3>
  21. #include <GuiListView.au3>
  22.  
  23. ; Only One Instance
  24. _Singleton(@ScriptName)
  25.  
  26. ; Options
  27. #NoTrayIcon
  28. Opt('WinTitleMatchMode', 2)
  29. Opt('GUIOnEventMode', 1)
  30. Opt('GUICloseOnESC', 0)
  31.  
  32. ; Script Start - Add your code below here
  33. #Region ### START Koda GUI section ### Form=
  34. Global $MainForm = GUICreate("Demo by Juno_okyo", 250, 236, -1, -1)
  35. GUISetFont(12, 400, 0, "Arial")
  36. GUISetOnEvent($GUI_EVENT_CLOSE, "MainFormClose")
  37. Global $ListView1 = GUICtrlCreateListView("User", 5, 5, 240, 185)
  38. _GUICtrlListView_SetColumnWidth(-1, 0, 235)
  39. GUICtrlCreateListViewItem("juno_okyo", $ListView1)
  40. GUICtrlCreateListViewItem("test", $ListView1)
  41. GUICtrlCreateListViewItem("admin", $ListView1)
  42. Global $Button1 = GUICtrlCreateButton("Add Item", 5, 200, 87, 25)
  43. GUICtrlSetOnEvent(-1, "AddBtn")
  44. GUICtrlSetCursor(-1, 0)
  45. Global $Button2 = GUICtrlCreateButton("Edit", 104, 200, 75, 25)
  46. GUICtrlSetOnEvent(-1, "EditBtn")
  47. GUICtrlSetCursor(-1, 0)
  48. GUISetState(@SW_SHOW)
  49. #EndRegion ### END Koda GUI section ###
  50.  
  51. While 1
  52.     Sleep(100)
  53. WEnd
  54.  
  55. Func AddBtn()
  56.     Local $item = InputBox('Add Item', 'Enter an item:')
  57.     If $item <> '' Then
  58.         GUICtrlCreateListViewItem($item, $ListView1)
  59.     EndIf
  60. EndFunc
  61.  
  62. Func EditBtn()
  63.     Local $item = _GUICtrlListView_GetSelectedIndices($ListView1)
  64.     Local $index = Int($item)
  65.     Local $text = _GUICtrlListView_GetItemText($ListView1, $index)
  66.     Local $new_text = InputBox('Edit Item', 'Enter a new value:', $text)
  67.     _GUICtrlListView_SetItemText($ListView1, $index, $new_text)
  68. EndFunc
  69.  
  70. Func MainFormClose()
  71.     Exit
  72. EndFunc
Add Comment
Please, Sign In to add comment