Public Sub Form_Open()
With TextBox1
.Font = Font["Mono noto,Bold, 24"]
End With
End
Public Sub TextBox1_KeyPress()
TextBox1.Insert(Upper(Key.Text))
Stop Event
End
Public Sub Form_Open()
With TableView1
.Rows.Count = 15
.Columns.Count = 1
.Font = Font["Mono noto, Bold, 24"]
End With
End
Public Sub TableView1_Click()
TableView1.Edit
End
Public Sub TableView1_Save(Row As Integer, Column As Integer, Value As String)
If Len(TableView1.Current.Text) >= 1 Then
Stop Event
Else
TableView1[Row, Column].Text = Upper(Value)
Endif
End
Public Sub TableView1_KeyPress()
Message.Info("La tecla pulsada es: " & Key.Text)
End
Cita:
This event is raised when the user requested an insertion by hitting the RETURN key inside the bottom-right cell.
(29-12-2022, 14:04)Shordi escribió: Tableview dispone de la propiedad "Editor" que es una referencia al control que se esté utilizando para edición (textbox o combobox). Deberías poder hacer con ella lo mismo que con un textbox individualizado.
Es cosa de probar
' Gambas class file
Private tb As TableView
Private masdeuncaracter As Boolean
Private miobservador As Observer
Public Sub Form_Open()
With Me
.w = 170
.h = 170
.Center()
End With
tb = New TableView(Me) As "ManipulaTabla"
With tb
.Rows.Count = 5
.Columns.Count = 1
.Font = Font["Noto Mono, Bold 24"]
.W = 150
.H = 150
.Left = 10
.Top = 10
End With
End
Public Sub ManipulaTabla_Click()
Dim tbxeditor As TextBox
tb.Edit()
tbxeditor = tb.Editor
miobservador = New Observer(tbxeditor) As "ManipulaCTexto"
End
Public Sub ManipulaTabla_Save(row As Integer, column As Integer, value As String)
tb[row, column].text = value
End
Public Sub ManipulaCTexto_Change()
If Len(Last.text) >= 1 Then masdeuncaracter = True
End
Public Sub ManipulaCTexto_KeyRelease()
masdeuncaracter = False
End
Public Sub ManipulaCTexto_KeyPress()
If masdeuncaracter Then
Stop Event
Else
Last.Insert(Upper(Key.Text))
Stop Event
Endif
End
Public Sub ManipulaCTexto_KeyPress()
If masdeuncaracter Or Len(Last.text) >= 1 Then
Stop Event
Else
Last.Insert(Upper(Key.Text))
Stop Event
Endif
End
Public Sub TextBox1_KeyPress()
If String.Len(TextBox1.text) > 0 Then Stop Event
End
' Gambas class file
Private tb As TableView
Private miobservador As Observer
Private tbxeditor As TextBox
Public Sub Form_Open()
With Me
.w = 170
.h = 170
.Center()
End With
tb = New TableView(Me) As "ManipulaTabla"
With tb
.Rows.Count = 5
.Columns.Count = 1
.Font = Font["Noto Mono, Bold 24"]
.W = 150
.H = 150
.Left = 10
.Top = 10
End With
End
Public Sub ManipulaTabla_Click()
tb.Edit()
tbxeditor = tb.Editor
miobservador = New Observer(tbxeditor) As "ManipulaCTexto"
End
Public Sub ManipulaTabla_Save(row As Integer, column As Integer, value As String)
tb[row, column].text = value
End
Public Sub ManipulaCTexto_KeyPress()
If String.Len(tbxeditor.text) > 0 Then Stop Event
End
(30-12-2022, 19:23)Shordi escribió: Verás que declaro el tbxeditor como private, menos lío para el compilador a la hora de crear y destruir las referencias al control, pero no por ello mejor que hacerlo local.