Sub AppStart (Form1 As Form, Args() As String)
mList.Initialize
mRows.Initialize
For i=1 To 20
Dim c As Component
c.Initialize(i)
mList.Add(c)
Next
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
DrawTablaView
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Private Sub DrawTablaView
'Columns Tableview
Dim columns() As String=Array As String("Code","Description")
Dim columnsSize As Map
columnsSize.Initialize
columnsSize.Put(0,100) 'Code
columnsSize.Put(1,tv.PrefWidth-100) 'Description
'Draw Columns
tv.Items.Clear
mRows.Clear
tv.SetColumns(columns)
For Each col In columnsSize.Keys
tv.SetColumnSortable(col,False)
tv.SetColumnWidth(col,columnsSize.Get(col))
Next
For Each c As Component In mList
Dim row(columns.Length) As Object
RowBuilder(row,c)
tv.Items.Add(row)
Next
End Sub
Private Sub RowBuilder(row() As Object, c As Component)
For i=0 To row.Length-1
Select Case i
Case 0 'Code
Dim lb As Label
lb.Initialize("lbCode")
lb.Text=NumberFormat(c.Code,1,0)
lb.Tag=c
row(i)=WrapControl(lb)
If (c.Code Mod 3)=0 Then CSSUtils.SetBackgroundColor(lb,fx.Colors.Green) 'Change backgroundcolor programmatically
Case 1
Dim tf As TextField
tf.Initialize("tfDescription")
tf.Text=c.Description
tf.Tag=c
row(i)=WrapControl(tf)
If (c.Code Mod 3)=0 Then CSSUtils.SetBackgroundColor(tf,fx.Colors.Green) 'Change backgroundcolor programmatically
End Select
Next
mRows.Put(c,row)
End Sub
Sub WrapControl(control As Object) As Pane
Dim pn As AnchorPane
pn.Initialize("")
pn.AddNode(control, 0, 0, -1, -1)
pn.FillHorizontally(control, 0, 0)
pn.FillVertically(control,0,0)
Return pn
End Sub
Private Sub tfDescription_FocusChanged (HasFocus As Boolean)
If HasFocus Then
Dim tf As TextField=Sender
tv.SelectedRow=RowIndexFromComponent(tf.tag)
End If
End Sub
Private Sub RowIndexFromComponent(c As Component) As Int
Dim ret As Int=-1
ret=tv.Items.IndexOf(mRows.Get(c))
Return ret
End Sub