Buchempfehlung
Windows System Programming
Windows System Programming
Das Kompendium liefert viele interessante Informationen zur Windows-Programmierung auf Englisch. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

GUI_Test (DataGrid)

Uploader:MitgliedLothar Schirm
Datum/Zeit:17.01.2015 16:43:27
Hinweis: Dieser Quelltext ist Bestandteil des Projekts Simple GUI, zu dem es auf FreeBASIC-Portal.de eine Projektseite gibt.

'===============================================================================
' GUI_Test_DataGrid.bas
' 15 January 2015
'===============================================================================

#Include "GUI.bas"

Dim Shared As DataGrid Table
Dim Shared As TextBox Text_row, Text_col, Text_item


Sub CreateWindow()
'Window

    Dim As Integer ColWidths(2) = {100, 300, 100}, i, j

    OpenWindow                              (540, 350, "DataGrid Test")
    Table = DataGrid_New            (20, 20, 9, 2, ColWidths())
    Var Label_row = Label_New   (20, 240, 120, 20, "Selected row:")
    Var Label_col = Label_New   (20, 270, 120, 20, "Selected column:")
    Var Label_item = Label_New(20, 300, 120, 20, "Item text:")
    Text_row = TextBox_New      (140, 240, 380, 20, "")
    Text_col = TextBox_New      (140, 270, 380, 20, "")
    Text_item = TextBox_New     (140, 300, 380, 20, "")

    'Set data into data grid:
    DataGrid_SetItem(Table, 0, 0, "Name")
    DataGrid_SetItem(Table, 0, 1, "Adress")
    DataGrid_SetItem(Table, 0, 2, "Phone Number")
    DataGrid_SetItem(Table, 1, 0, "William Smith")
    DataGrid_SetItem(Table, 1, 1, "London, 23 Baker Street")
    DataGrid_SetItem(Table, 1, 2, "456789123")
    DataGrid_SetItem(Table, 2, 0, "Goldie Hawn")
    DataGrid_SetItem(Table, 2, 1, "New York, 45 North Highway")
    DataGrid_SetItem(Table, 2, 2, "1234567")
    DataGrid_SetItem(Table, 3, 0, "Otto Meier")
    DataGrid_SetItem(Table, 3, 1, "Berlin, Krumme Lanke 27")
    DataGrid_SetItem(Table, 3, 2, "34892344")
    DataGrid_SetItem(Table, 4, 0, "Pierre Dupont")
    DataGrid_SetItem(Table, 4, 1, "Nantes, Rue de la Gare 51")
    DataGrid_SetItem(Table, 4, 2, "7725622")

End Sub


Sub Table_Handle_Event()
'Event Handler

    Dim As Integer row, col

    DataGrid_GetIndexes(Table, row, col)
    TextBox_SetText(Text_row, Str(row))
    TextBox_SetText(Text_col, Str(col))
    TextBox_SetText(Text_item, DataGrid_GetItem(Table, row, col))
    If row > 0 Then DataGrid_EditItem(Table, row, col)

End Sub



'Main:

CreateWindow()

Do
    If DataGrid_Event(Table) Then Table_Handle_Event()
Loop Until Window_Event_Close

End