Attached you have a modified version of the TableExample program with row and column lines.
The line color is the ScrollView.Panel.Color.
So the row and column line colors are the same.
The line width can be set in the ColLineWidth and RowLineWidth variables.
The lines are generated by shifting the lables by the line width. That means that the Label.Width is equal to the column width minus the line width and the same for the height.
An other question. Can I set up different actions for different cells??I'm working over example v1.2, but I have some problems:
- How can I change of each one of the columns?
- Can I show images or links inside grid?
- I'm using Latin characters inside de CSV file, but they aren't showed well.
- How can I convert code to a module?
Sub GetView(Row As Int, Col As Int) As Label ' Returns the label in the specific cell Dim L As Label L = Table.GetView(Row * NumberOfColumns + Col) Return L End Sub Sub AddRow(Values() As String) ' Adds a row to the table Dim ColWidth As Int If Values.Length <> NumberOfColumns Then Log("Wrong number of values.") Return End If ColWidth=0 For i = 0 To NumberOfColumns - 1 Dim L As Label L.Initialize("cell") L.Text = Values(i) L.Gravity = Alignment(i) L.TextSize = FontSize(i) L.TextColor = FontColor(i) L.Color=CellColor(i) Dim rc As RowCol rc.Initialize rc.Col = i rc.Row = NumberOfRows L.Tag = rc Table.AddView(L, ColWidth, RowHeight * NumberOfRows, ColumnWidth_1(i), RowHeight_1) ColWidth=ColWidth+ColumnWidth(i) If i = 0 AND GetView(rc.Row,1).Text = "Something" Then L.Color = Colors.Red 'this is what I added. Basically, for Col0 only, if the cell after (same row, Col1) says "something", 'I want Col0's cell to be red for that line, otherwise stay as predefined. However when I use this 'construct, it tells me View should be initialised first. And I'm not too sure it will work anyway. Next NumberOfRows=NumberOfRows+1 Table.Height = NumberOfRows * RowHeight End Sub
For i = numberOfColumns-1 To 0 step -1
If i = 0 AND GetView(rc.Row,1).Text = "Something" Then L.Color = Colors.Red
If i = 0 AND Table.GetView(rc.Row * NumberOfColumns + 1).Text = "Something" Then L.Color = Colors.Red
Table.AddView(L, ColWidth, RowHeight * NumberOfRows, ColumnWidth_1(i), RowHeight_1)