Second click on table cell

PatrikL

Member
Licensed User
Hi,

I need help with this problem.

I need procedure for click on table cell. On first click I need select cell, on second click I want do something. But table dont have event onClick. Exist any workaround? This is my test code, but this code dont work.

B4X:
Sub Globals
   'Declare the global variables here.
   Dim crow
   Dim ccol
End Sub

Sub App_Start
   Form1.Show
   Table1.AddCol (cNumber, "ID", 50, True)
   Table1.AddCol (cString, "Name", 50)
   Table1.AddRow (234564, "John")
   Table1.AddRow (987654, "Kate")
End Sub



Sub Table1_SelectionChanged (ColName, Row)
   If ((crow = Row) AND (ccol = ColName)) Then
      Msgbox("Click on " & Table1.Cell(ColName,Row))
   End If   
   crow = Row
   ccol = ColName
End Sub
 

agraham

Expert
Licensed User
Longtime User
It is possible to add a MouseDown event

I tried that but it doesn't work. Once the cell is selected the Textbox hosted by the Table gets the focus and the Table (DataGrid) itself gets no more events so you see the first MouseDown event but not the second. :(

I believe it can be done in C# but it is a bit laborious as it involves installing event handlers on the Textbox in each DataGridTextBoxColumn and that only works on the desktop anyway as the device doesn't have the DataGridTextBoxColumn.TextBox property needed.
 

Cableguy

Expert
Licensed User
Longtime User
Hi,

I need help with this problem.

I need procedure for click on table cell. On first click I need select cell, on second click I want do something. But table dont have event onClick. Exist any workaround? This is my test code, but this code dont work.

How about a simple flag?
Something like this:

B4X:
Sub Globals
   'Declare the global variables here.
   Dim crow
   Dim ccol
End Sub

Sub App_Start
   Form1.Show
   Table1.AddCol (cNumber, "ID", 50, True)
   Table1.AddCol (cString, "Name", 50)
   Table1.AddRow (234564, "John")
   Table1.AddRow (987654, "Kate")
End Sub



Sub Table1_SelectionChanged (ColName, Row)
   If ((crow <> Row) AND (ccol <> ColName)) Then
             'First click
      Msgbox("1st Click on " & Table1.Cell(ColName,Row))
                          crow=Row
                          ccol=ColName
             Else If ((crow = Row) AND (ccol = ColName)) Then
             'Second click
                         Msgbox("2nd Click on " & Table1.Cell(ColName,Row))
   End If   
End Sub
[/QUOTE]
 

LineCutter

Active Member
Licensed User
Longtime User
Fake the cell activation (draw a box around the cell in the foreground layer) & redirect the selection to another (invisible) cell. Set a flag & check that on table selection_changed??
 
Top