Tables - Cell Click

jjspike

Member
Licensed User
Longtime User
Hello,

I am new to the realm of PDA development and have not coded for close to 15 years. I really enjoy using basic4android and find it very "gentle" on the system! I have been working on my first app and ran into an issue with tables and the "click" events.
I populated my table with data from a SQL server (thanks for the tutorial) and would like to display text when a cell or header is clicked. I created a handler to handle this event in this manner:

Sub Globals
Dim btnButton1 As Button
Dim edtText1 As EditText
Dim lblLabel1 As Label
Dim tblTable As Table

End Sub

.
.
.


Sub tblTable_CellClick
ToastMessageShow("Cell click", False)
End Sub

Sub tabTable_HeaderClick
ToastMessageShow("Header click", False)
End Sub

When I click on any cell or header, the handler code is never called. I created a button handler as such and it works fine:

Sub btnButton1_Click
If edtText1.Text <> "" Then
lblLabel1.Text = edtText1.Text
Else
lblLabel1.Text = "!! ENTER TEXT !!"
ToastMessageShow("Enter text to copy", False)
End If


End Sub

Can anyone assist with this?

Cheers!
 
In your routines you are missing the parameters:
Code:
Sub tblTable_CellClick(Col As Int, Row As Int)
      ToastMessageShow("Cell click Col = " & Col & " Row = " & Row , False)
End Sub
and
Code:
Sub tblTable_HeaderClick(Col As Int)
       ToastMessageShow("Header click Col = " " Col, False)
End Sub
Do you have two tables ?
You use 'tblTable' for CellClick and 'tabTable' for HeaderClick ?
Best regards.
 
Upvote 0
Thank you so much for your reply Klaus! I have only one table however I chaged the name a number of times and entered a typo. I have added the parameters and still no luck. In fact, I copied your code and directly replaced what I had. I did notice that the first time when I keyed in the parameters, the help did not appear to indicate that I had to enter two integer parameters. It is almost as if the "Table" module has not registered. Any further ideas? I must have messed up something really bad or made a silly error as this does not seem difficult.

Thanks again!!



In your routines you are missing the parameters:
Code:
Sub tblTable_CellClick(Col As Int, Row As Int)
      ToastMessageShow("Cell click Col = " & Col & " Row = " & Row , False)
End Sub
and
Code:
Sub tblTable_HeaderClick(Col As Int)
       ToastMessageShow("Header click Col = " " Col, False)
End Sub
Do you have two tables ?
You use 'tblTable' for CellClick and 'tabTable' for HeaderClick ?
Best regards.
 
Upvote 0
You must replace this line
tblTable.Initialize(Me, "Users", 3)

by this line
tblTable.Initialize(Me, "tblTable", 3)

You set Users as the EventName but you call the routines tblTable_Click and tblTable_HeaderClick ?

You could also leave tblTable.Initialize(Me, "Users", 3) as it is
and rename the event routines Users_Click and Users_HeaderClick

Best regards.
 
Upvote 0
Thank you Klaus. Earlier on as I was testing various features and totally overlooked the fact that I had made this change. I was so confident that I did not do anything dumb that I did not look at that area of the code. Again, I have not coded for 15 years and my brain is very rusty! :sign0013:

I apologize for this and thank you very much for your fantastic support!! You are a true star!

Thank you



You must replace this line
tblTable.Initialize(Me, "Users", 3)

by this line
tblTable.Initialize(Me, "tblTable", 3)

You set Users as the EventName but you call the routines tblTable_Click and tblTable_HeaderClick ?

You could also leave tblTable.Initialize(Me, "Users", 3) as it is
and rename the event routines Users_Click and Users_HeaderClick

Best regards.
 
Upvote 0
Back
Top