B4J Question tableview

elitevenkat

Active Member
Licensed User
Longtime User
B4X:
Sub ShowTales(rset As DBResult)
               Dim lmap As Map
                lmap.Initialize
                lmap.Clear
                tvTables.Items.Clear
                tvTables.SetColumns(Array As String("T0","T1", "T2", "T3","T4","T0","T1", "T2","f9","f10"))
                Dim nc As Int=10
                Dim i  As Int
                Dim t As Int
                For i=0 To tvTables.ColumnsCount-1
                  tvTables.SetColumnWidth(i,97)   
                  tvTables.SetColumnHeader(i,"")
                  tvTables.SetColumnSortable(i,False)
                Next
                tvTables.SingleCellSelection=True
                Dim tc(nc) As Object
                 
                For Each row() As Object In rset.Rows
                     
                    Dim lbl As Label
                   
                   
                    lbl.Initialize("lbl")
                    lbl.Text=row(1)
                    lbl.SetSize(85,85)
                   
                    lmap.Put("tablepckey",row(0))
                    lmap.Put("occupied",row(3))
                    lmap.Put("currentcaptainname",row(4))
                    lmap.Put("currentwaitername",row(5))
                    lmap.Put("currentlyoccupiedpax",row(6))
                    lmap.Put("unsettled",row(7))
                    lmap.Put("billpckey",row(8))
                   
                    lbl.Alignment="CENTER"
                    lbl.Style="-fx-background-color: green"
                    lbl.TextColor=fx.Colors.White
                    lbl.Font=fx.DefaultFont(20)
                    If  lmap.Get("occupied") Then
                       lbl.Style="-fx-background-color: red"   
                       
                    End If
                    If  lmap.Get("unsettled") Then
                       lbl.Style="-fx-background-color: yellow"   
                        lbl.TextColor=fx.Colors.black
                    End If
                   
                   lbl.Tag=lmap   
                    tc(t)=lbl 
                   
                    t=t+1
               
           
                    If t >nc-1 Then
                      Dim tc1(nc) As Object
                      Dim ci As Int
                      t=0
                     
                      For ci=0 To nc-1
                         tc1(ci)=tc(ci)   
                         
                         tc(ci)=""
                      Next
                      tvTables.Items.Add(tc1)   
                    '  tvTables.Items.Add(tc)
                       
                    End If
                               
                Next
               
                If t>0 Then
                     Dim tc1(nc) As Object
                      Dim ci As Int
                      t=0
                      For ci=t To nc-1
                         tc1(ci)=tc(ci)   
                      Next
                      tvTables.Items.Add(tc1)
               End If

End Sub



Sub Lbl_MouseClicked(EventData As MouseEvent)
    Dim l As Label
    l=Sender
    Dim lm1 As Map
    lm1=l.Tag
    fx.Msgbox(MainForm, lm1.Get("tablepckey"),"tablepckey")
   
   

End Sub

sub show table is functioning as expected. (screen shot 1)

the lblmouseclicked event is not firing

there are no other events for tvtables tableview

what is wrong in the above code
 

Attachments

  • b4a.png
    b4a.png
    69.1 KB · Views: 221

klaus

Expert
Licensed User
Longtime User
I suppose that the problem is here.
You declare
lbl.Initialize("lbl")
then you declare the event with
Sub Lbl_MouseClicked(EventData AsMouseEvent)
One time lbl and the other time Lbl !?
You need to be consistent in the declarations they are case sensitive.
 
Upvote 0

elitevenkat

Active Member
Licensed User
Longtime User
@klaus. I fond the problem. on focus (true) of a view, i was calling this showtable sub and on focus (hasfocus false) i was closing this showtable panel.
that was the reason for Lbl_MouseClicked(EventData AsMouseEvent) not getting fired.

i had removed the code from hasfocus=false part from the onfocus event of that control and the Lbl_MouseClicked(EventData AsMouseEvent) is firing (it seems sub events are not case sensitive !!!)

Once again thank you for spending your valuable time and the quick response
 
Upvote 0
Top