Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Keep selected row with TableSort

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-06-2009, 01:34 PM
Basic4ppc Veteran
 
Join Date: Dec 2008
Posts: 203
Awards Showcase
Beta Tester 
Total Awards: 1
Default Keep selected row with TableSort

Is it possible to do a table sort and keep the currently selected row selected?
I know I could do that by putting the cells of that row in a variable and then after the sort loop through the table, find that row and select it, but that would be too slow.

RBS
Reply With Quote
  #2 (permalink)  
Old 01-06-2009, 10:10 PM
Basic4ppc Veteran
 
Join Date: Dec 2008
Posts: 203
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Actually performance is not bad when I do code like this:

Before the sort:

Sub MarkPreSortRow(lRow)

Table1.AddCol(cNumber, "MarkPreSortRow", 0, False)
Table1.Cell("MarkPreSortRow", lRow) = 1

End Sub


And after the sort:

Sub SelectPreSortTableRow(strColumnName)

Dim i

For i = 0 To Table1.RowCount - 1
If Table1.Cell("MarkPreSortRow", i) = 1 Then
Table1.RemoveCol("MarkPreSortRow")
Table1.SelectCell(strColumnName, i)
Return
End If
Next i

End Sub


And I take it there is nothing better than this.


RBS
Reply With Quote
  #3 (permalink)  
Old 01-08-2009, 05:19 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

If your table includes a unique key you can just save this key and search for it after resorting.
It is almost always a good idea to have a unique key for each row.
Reply With Quote
  #4 (permalink)  
Old 01-08-2009, 04:02 PM
Basic4ppc Veteran
 
Join Date: Dec 2008
Posts: 203
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Good point. Some of the tables indeed have a unique key and in that case I could maybe save a bit of time by not adding the extra column.
To add the unique key if I don't otherwise need it won't probably be worth it.

RBS
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Treeview - getting the selected branch blackbox Questions (Windows Mobile) 4 12-05-2009 10:35 PM
Selected item to top of ListBox HARRY Questions (Windows Mobile) 4 12-19-2008 08:35 AM
Get and update selected cell in ListView tsteward Questions (Windows Mobile) 5 04-29-2008 03:45 PM
Settings for User's selected 'theme' willisgt Questions (Windows Mobile) 2 02-21-2008 04:06 PM
Tablecell 0 not selected Scubaticus Bug Reports 4 07-30-2007 09:03 PM


All times are GMT. The time now is 08:01 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0