fb:porticula NoPaste
GUI_Test (ListBox)
Uploader: | Lothar Schirm |
Datum/Zeit: | 17.01.2015 16:42:20 |
Hinweis: Dieser Quelltext ist Bestandteil des Projekts Simple GUI, zu dem es auf FreeBASIC-Portal.de eine Projektseite gibt.
'===============================================================================
' GUI_Test_Listbox.bas
' Jan 17, 2015
'===============================================================================
#Include "GUI.bas"
Dim Shared As ListBox LB
Dim Shared As TextBox Text_Add, Text_index, Text_text
Dim Shared As Button Button_Add, Button_SetItem, Button_Delete
Dim Shared As Integer index
Sub OpenWindow_Main()
'Fenster
Dim As Integer i
OpenWindow (400, 440, "Test Listbox")
LB = ListBox_New (20, 20, 150, 400)
Text_Add = TextBox_New (200, 100, 150, 20, "")
Button_Add = Button_New (200, 130, 80, 20, "Add")
Var Label_index = Label_New (200, 160, 150, 20, "Index:")
Text_index = TextBox_New (200, 180, 150, 20, "")
Var Label_text = Label_New (200, 210, 150, 20, "Text:")
Text_text = TextBox_New (200, 230, 150, 20, "")
Button_SetItem = Button_New (200, 260, 80, 20, "Set Text")
Button_Delete = Button_New (200, 350, 150, 20, "Clear Listbox")
For i = 0 To 20
ListBox_Add(LB, "Item number: " + Str(i))
Next
End Sub
Sub LB_EventHandler()
'Event handler of Listbox
Dim As String text
index = ListBox_GetIndex(LB)
text = ListBox_GetItem(LB, index)
TextBox_SetText(Text_index, Str(index))
TextBox_SetText(Text_text, text)
End Sub
'Main:
OpenWindow_Main()
Do
If ListBox_Event(LB) Then LB_EventHandler()
If TextBox_Event(Text_Add) Then TextBox_Edit(Text_Add)
If Button_Event(Button_Add) Then ListBox_Add(LB, TextBox_GetText(Text_Add))
If TextBox_Event(Text_text) Then TextBox_Edit(Text_text)
If Button_Event(Button_SetItem) Then ListBox_SetItem(LB, index, TextBox_GetText(Text_text))
If Button_Event(Button_Delete) Then ListBox_Clear(LB)
Loop Until Window_Event_Close
End