B4J Question TableView index

ThRuST

Well-Known Member
Licensed User
Longtime User
That's right, how to access a tableview index which is needed for use with RemoveAt, anyone?
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Awesome :) I will try that.

UPDATE: It worked perfectly, thanks.
 
Last edited:
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
btw Enrique what is the equal to selecteditem or text to read an item in the tableview?
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
This is how you read what's being selected in a TableView.

B4X:
Sub TableView_MouseClicked (EventData As MouseEvent)
  
Dim x as int = 1
Textbox1.Text = TableView.SelectedRowValues(x)

End Sub

where x is the column in the tableview. 0 - ?
So in this example the second column.
 
  • Like
Reactions: crt
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
oh i see you answered! good..

if you want any other value aside from the selecteditem (for example another index)

B4X:
dim r() as string = tableview.items.get(5)
textbox1.text = r(0)
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
How do you select an item in the tableview from its index (selectedrow) value?

When adding a new item to the tableview I use tableview.scrollto(lastitem) and then I want to autoselect it. But how?
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Btw, this is how you change it

B4X:
Dim row() As Object = TableView.Items.Get(row number)
row(5) = "hello Enrique :)"
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
I solved it myself :) This is how you autoselect the last added item in a tableview

B4X:
                 ' Select the latest added item in a tableview
        Dim lastitem As Int
        lastitem = TableView.Items.Size - 1
        TableView.ScrollTo(lastitem)
        TableView.SelectedRow = lastitem

You've been ThRuSTed :D
 
Upvote 0
Top