Persistence of table cell selection

mjcoon

Well-Known Member
Licensed User
I'm showing a simple table that includes a unique numeric sort column.

I want to allow the user to select a row (unfortunately I cannot only show a selected cell, but that is only a cosmetic quibble) and then specify that the row be moved up or down in the sequence.

I do this by changing the value in the sort cell, using an intermediary "+0.5" value to maintain the uniqueness. While doing this the Sort naturally changes the row number of the tweaked row. I can cope with this, with a bit of brain pummelling, plus a global that stops the invocations of my _SelectionChanged(ColumnName, RowIndex) Sub having any effect when the change in selection is due to this sorting and not user action.

But the selected cell is not showing up as I expect. What are the rules for which cell is considered to be selected when actions such as filtering or sorting, or for that matter adding a new row, take place? And can a cell be considered to be selected while not being shown as such (by inverse font)?
 

linum

Active Member
Licensed User
I don't know if this can help you but It's worth giving it a shot. I have a program where selected rows change constantly so I can't rely on a SelectedIndex of a table (because it obviously changes all the time), so what I do is I check the table for a value and when it finds it I have it give me it's current row location.

Something like this:


B4X:
'first declare FoundIndex on your Globals

XName = txtName.txt

For i = 0 To tblData.RowCount -1            
        If tblData.Cell("Column Name", i) = XName Then
         FoundIndex = i            
   End If      
Next

Now you should be able to use FoundIndex as the new selected index (the exact location on your table) of the data you are trying to refer to.

I'm not sure if this is what you needed, if not then please disregard...
 

mjcoon

Well-Known Member
Licensed User
Hi Linum, that didn't hit the spot, so I'm in disregard mode... :sign0161::sign0161:

My problem is at least partly about the visible selection since the user is meant to be viewing my table. I get on OK with hidden ones!
 
Top