$hData[10, 10] AS String
$hColor[10, 10] AS Integer
$iCurRow AS Integer
$iCurColumn AS Integer
PUBLIC SUB Form_Open()
DIM x AS Integer
DIM y AS Integer
'TableView vergrößern
TableView1.Rows.Count = 10
TableView1.Columns.Count = 10
'und mit Werten füllen
FOR x = 0 TO 9
TableView1.Columns[x].Title = x + 1
FOR y = 0 TO 9
$hData[x, y] = "Z " & (x + 1) & " - S " & (y + 1)
$hColor[x, y] = &HFFFFFF& 'Standard-Hintergrundfarbe Weiß
NEXT
NEXT
'einige Zellen farbig
$hColor[7,3] = &HFF00FF&
$hColor[3,1] = &H00FFFF&
$hColor[4,5] = &H0000FF&
$hColor[9,0] = &H00FF00&
$hColor[3,4] = &HFF0000&
TableView1.Refresh
TextBox1Hide 'Die TextBox vorerst verschwinden lassen
ME.Center
END
PUBLIC SUB Button1_Click()
ME.Close
END
PUBLIC SUB TableView1_Data(Row AS Integer, Column AS Integer)
TableView1.Data.Text = $hData[Row, Column]
TableView1.Data.Background = $hColor[Row, Column]
END
PUBLIC SUB TableView1_Click()
'die angeklickte Zelle merken
$iCurRow = TableView1.Row
$iCurColumn = TableView1.Column
TextBox1Show
END
PUBLIC SUB TextBox1Show()
TableView1.MoveTo($iCurRow, $iCurColumn)
WITH TableView1[$iCurRow, $iCurColumn]
'den Text der angeklickten Zelle in die TextBox kopieren
TextBox1.Text = .Text
'und die TextBox genau über die Zelle plazieren
TextBox1.Move(TableView1.X + .X + 1, TableView1.Y + .Y, .W - 1, .H)
END WITH
WITH TextBox1
.Background = $hColor[$iCurRow, $iCurColumn]
.Border = FALSE
.Raise
.Show
.SetFocus
END WITH
END
PUBLIC SUB TextBox1Save()
IF $hData[$iCurRow, $iCurColumn] <> TextBox1.Text THEN
$hData[$iCurRow, $iCurColumn] = TextBox1.Text
TableView1.Refresh
ENDIF
TextBox1Hide
END
PUBLIC SUB TextBox1Hide()
TextBox1.Hide
END
PUBLIC SUB TextBox1_KeyPress()
DIM iPos AS Integer
SELECT Key.Code
CASE Key.Up
IF $iCurRow > 0 THEN
iPos = TextBox1.Pos
TextBox1Save
DEC $iCurRow
TextBox1Show
TextBox1.Pos = iPos
ENDIF
CASE Key.Down
IF $iCurRow < TableView1.Rows.Count - 1 THEN
iPos = TextBox1.Pos
TextBox1Save
INC $iCurRow
TextBox1Show
TextBox1.Pos = iPos
ENDIF
CASE Key.Left
IF $iCurColumn > 0 THEN
IF TextBox1.Pos = 0 OR Key.Control = TRUE THEN
TextBox1Save
DEC $iCurColumn
TextBox1Show
TextBox1.Pos = If(Key.Control = TRUE, 0, TextBox1.Length)
STOP EVENT
ENDIF
ENDIF
CASE Key.Right
IF $iCurColumn < TableView1.Columns.Count - 1 THEN
IF TextBox1.Pos = TextBox1.Length OR Key.Control = TRUE THEN
TextBox1Save
INC $iCurColumn
TextBox1Show
STOP EVENT
TextBox1.Pos = If(Key.Control = TRUE, TextBox1.Length, 0)
ENDIF
ENDIF
CASE Key.Return
TextBox1Save
IF $iCurColumn < TableView1.Columns.Count - 1 THEN
INC $iCurColumn
ELSE IF $iCurRow < TableView1.Rows.Count - 1 THEN
INC $iCurRow
$iCurColumn = 0
ELSE
$iCurRow = 0
$iCurColumn = 0
ENDIF
TextBox1Show
TextBox1.Pos = TextBox1.Length
CASE Key.Esc
TextBox1Hide
END SELECT
END
PUBLIC SUB TableView1_MouseDown()
IF TextBox1.Visible = TRUE THEN TextBox1Save
END
PUBLIC SUB TableView1_MouseWheel()
IF TextBox1.Visible = TRUE THEN TextBox1Save
END