editable table ?

giannimaione

Well-Known Member
Licensed User
Longtime User
Hi all,
is there a method for make table editable?

Gianni
 

giannimaione

Well-Known Member
Licensed User
Longtime User
Is it possible to edit a TABLE?
 

specci48

Well-Known Member
Licensed User
Longtime User
Hi Gianni,

there is no method for an editable table.
But in the old and lost forum :sign0148: sloopa has provided a code sample as an workaround:

From sloopa:

Version 0.9 of an editable table.

Only "Backspace" for correcting cell-entry works (no cursor-keys (arrow-keys) Embarassed I don't know the word in englisch)

Blinking cursor don't works 100% (sometimes the last letter of the cell-entry blinks for one time)
If you make improvements - please let me know and post it here

B4X:
' Editable Tablecell
' ==================
' Add a form1
' Add a textbox1
' Add a table1
' Add a timer1
'
' !!WORKS ONLY ON PPC!!

Sub Globals
   scol = ""
   srow = 0
   I = -1
   scolh = "hidden"
End Sub

Sub App_Start
   Form1.show
   sip(false) ' keine Tastatur
   table1.addcol(cString, "hidden", 0)
   table1.addcol(cString, "Name", 60)
   table1.addcol(cString, "Vorname", 60)
   table1.addrow()
   textbox1.visible = false
End Sub

Sub Table1_SelectionChanged (ColName, Row)
   scol = ColName
   srow = Row
   if table1.selectedcol = "hidden" then
         return ' Abbruch
   end if
   I = -1
   timer1.enabled = true
   SIP(true)
   table1.cell(scolh,srow) = table1.cell(scol,srow) ' Hilfszelle bekommt den Wert der Zelle
End Sub

Sub TextBox1_KeyPress (key)
   if key = chr(13) then  ' Return gedrückt   
      table1.focus = true
      SIP(false)          
      timer1.enabled = false        
      CellFinal
      table1.selectcell("hidden",srow)
      return
   end if
   if key =chr(8) then ' Backspace gedrückt
      if StrLength(table1.cell(scolh,srow)) > 0 then
         cellstr = table1.cell(scolh,srow)
         newstr = substring(cellstr, 0, StrLength(cellstr)-1)
         table1.cell(scolh,srow) = newstr
         table1.cell(scol,srow) = table1.cell(scolh,srow)
         return
      else
         return ' wenns = 0 ist nur return, ansonsten wird ein Block angezeigt
      end if
   end if
   table1.cell(scolh,srow) = table1.cell(scolh,srow) & key
   CellFinal
End Sub

Sub CellFinal
   table1.cell(scol,srow) = table1.cell(scolh,srow)
End Sub

Sub Timer1_Tick
   if I < 0 then
      BlinkOn
   else
      BlinkOff
   end if
   I = I *(-1)
   textbox1.Focus = true
End Sub

Sub BlinkOn
   table1.cell(scol,srow) = table1.cell(scolh,srow) & "I"
End Sub

Sub BlinkOff
   if StrLength(table1.cell(scol,srow)) <> 0 then
         table1.cell(scol,srow) = substring(table1.cell(scol,srow), 0, StrLength(table1.cell(scol,srow))-1)
   end if
End Sub
 
Top