B4J Question Tableview delete a row

davelew1s

Active Member
Licensed User
Longtime User
Hi!
I am trying to delete 1 row in a tableview by clicking on column 2 using the following:-

Sub tv1_SelectedCellChanged (RowIndex As Int, ColIndex As Int, Cell As Object)
If ColIndex = 1 Then
tv1 .Items .RemoveAt (tv1 .SelectedRow )
tv1.SelectedRow = -1 'If this line omitted all rows avove are deleted
End If
End Sub

as it is it deletes 2 rows if ' tv1.SelectedRow = -1 ' is not in it deletes all rows above the selected one.
Any help or thought on this .
Thanks Dave.
 

davelew1s

Active Member
Licensed User
Longtime User
Sorry Erel won't happen again...after alot of playing I got it to work ok as follows:-

B4X:
Sub tv1_SelectedCellChanged (RowIndex As Int, ColIndex As Int, Cell As Object)
If ColIndex = 1 Then
  tv1 .SingleCellSelection = False
  tv1 .Items .RemoveAt (tv1 .SelectedRow )
  tv1 .SingleCellSelection =true
End If
End Sub

Dave.
 
Upvote 0
Top