B4J Question TableView table column position

powerino

Active Member
Licensed User
Hello everyone, I have a TableView that shows me the contents of a table (SQLITE) and I would like to prevent you from changing the position of the columns (for example move Field3 after Field4). How can I BLOCK this move? Thank you
 

Attachments

  • b4j.png
    b4j.png
    44.6 KB · Views: 213

powerino

Active Member
Licensed User
Hi, i have tested this code
B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private tv As TableView
   Private suspended As Boolean
   Private items As List
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.Show
   tv.Initialize("tv")
  
   MainForm.RootPane.AddNode(tv, 10, 10, 400, 400)
   items.Initialize
   For i = 1 To 100
     items.Add(Array(i, i + 1, i + 2))
   Next
   SetTable
   Dim jo As JavaObject = tv
   Dim e As Object = jo.CreateEvent("javafx.collections.ListChangeListener", "colchange", Null)
   jo.RunMethodJO("getColumns", Null).RunMethod("addListener", Array(e))
End Sub

Sub SetTable
   tv.SetColumns(Array("col1", "col2", "col3"))
   tv.items = items
   tv.SetColumnWidth(0,100)
   tv.SetColumnWidth(1,100)
   tv.SetColumnWidth(2,100)
End Sub

Sub colchange_Event (MethodName As String, Args() As Object) As Object
   Dim change As JavaObject = Args(0)
   change.RunMethod("next", Null)
   If change.RunMethod("wasReplaced", Null) AND Not(suspended) Then
     suspended = True
     SetTable
     suspended = False
   End If
   Return Null
End Sub

but i have tje same problem... ERROR: "Unexpected event (missing RaiseSynchronousEvents): colchange_event
java.lang.Exception: Stack trace"
 
Upvote 0
Top