$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
'für dieses Beispiel gelben Hintergrund setzen
'damit man sieht, wann und wo die TextBox auftaucht
TextBox1.Background = &HFFFF00&
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()
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
.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()
IF Key.Code = Key.Return THEN TextBox1Save
IF Key.Code = Key.Esc THEN TextBox1Hide
END
PUBLIC SUB TableView1_MouseDown()
IF TextBox1.Visible = TRUE THEN TextBox1Save
END
PUBLIC SUB TableView1_MouseWheel()
IF TextBox1.Visible = TRUE THEN TextBox1Save
END