Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


table: SelectionChanged() and SelectedRow


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-28-2007, 10:21 PM
Junior Member
 
Join Date: Apr 2007
Location: Germany
Posts: 34
Default table: SelectionChanged() and SelectedRow

Situation:
I have a form with an empty table. Then I populate the table with a few data rows from a CSV file. No table cell is selected after filling the table.
When I now call table1.SelectedRow the result is 0 ... so I don't know wether no cell was selected so far or wether the first row was really selected.
But I am a clever one ... I defined a global var named actualRow and an SelectionChanged-event:
Quote:
Sub Globals
actualRow = -1
End Sub
Sub TableEinheiten_SelectionChanged (ColName, Row)
aktRow = Row
End Sub
So I'm able to check an explicit cell selection .

Problem:
This works only for the first time. After the cell selection is handled by the program I can reset actualRow to -1 but I can't deselect the cell.
And if the user taps on the table header or elsewhere outside the table and deselects the cell, I have no event to get noticed about deselection.


It would be useful if SelectedRow and SelectedCol would return -1 if no cell is actually selected.

Edit: table1.Refresh or table1.SelectCell("col1", -1) don't deselect.
__________________
iPAQ 6515, MDA compact

Last edited by stbi : 06-28-2007 at 10:29 PM.
Reply With Quote
  #2 (permalink)  
Old 06-28-2007, 11:06 PM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Greece
Posts: 353
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

I think that you have no chance to remove the selection this way. Try to remove selected row and add it again.
Didn't testit.
__________________
Dimitris Zacharakis
http://www.terracom.gr
Reply With Quote
  #3 (permalink)  
Old 06-29-2007, 11:18 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 485
Awards Showcase
Beta Tester 
Total Awards: 1
Default

I think but am not sure that all is needed is to move the focus onto a different control.
You could possibly try moving the focus onto the Form.

Please let me know if this works.

Thanks,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #4 (permalink)  
Old 06-29-2007, 02:01 PM
Junior Member
 
Join Date: Apr 2007
Location: Germany
Posts: 34
Default

Quote:
Originally Posted by RandomCoder View Post
I think but am not sure that all is needed is to move the focus onto a different control. You could possibly try moving the focus onto the Form.
Moving the focus to another control works, but moving the focus to the form doesn't work. The control must be visible, if you want an unvisible control you can use a button with size 0,0. One disadvantage remains: if the user selects the same row and taps the same cell, the SelectionChanged-event is not fired (because really nothing changed).

I found another solution: SelectCell() to an invisible (colwidth=0) cell in the first row. So every tap on a cell fires the SelectionChanged-event.

But thank you RandomCoder, your tip led me back on track

@dzt: thank you, too! I didn't test your solution because I had a bad feeling about deleting master data. And I presume that cell slection will remain active.
__________________
iPAQ 6515, MDA compact
Reply With Quote
  #5 (permalink)  
Old 06-29-2007, 03:07 PM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Greece
Posts: 353
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Well I think that,

moving the focus to another control even with width and height=0 doesn't remove the selection from table control (just removes the focus)

making a length=0 cell prevents it from beeing selected by the stylus, but doesn't prevents it from beeing selected by the arrow keys.

Not very sure for the above

Regards
__________________
Dimitris Zacharakis
http://www.terracom.gr
Reply With Quote
  #6 (permalink)  
Old 12-17-2007, 04:58 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 154
Default

stbi, I'm having a small problem with this solution.

I create a table, create the columns, and assign the cell values one row at a time. Finally, I try a SelectCell(), and get the error:

'CurrentCell could not be set at this time. Moving your code to the Form.Load event should solve this problem.'

Any ideas?

Gary
Reply With Quote
  #7 (permalink)  
Old 12-17-2007, 05:39 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 636
Default

Hello willisgt,

I think you are trying to select the tablecell within an event sub. There are some commands (i don't know them all) you cannot execute within such an event sub.
Look at this thread Showing a form in a SelectionChanged event and try to use a timer to solve your problem.


specci48
Reply With Quote
  #8 (permalink)  
Old 12-21-2007, 04:14 AM
alfcen's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu
Posts: 424
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi willisgt

I eliminate this error message by using SelectCell after Form.Show (the form that contains the table). Example:

Code:
Sub mnuSetting_Click
  If tblCity.RowCount < 1 Then
    tblCity.LoadCSV("citylist.csv",",",true,true)
    tblCity.ColWidth(tblCity.Colname(0))=tblCity.Width / 2 - 10
    tblCity.ColWidth(tblCity.Colname(1))=tblCity.Width / 2 - 10
    tblCity.ColWidth(tblCity.Colname(2))=0
    tblCity.ColWidth(tblCity.Colname(3))=0
    tblCity.ColWidth(tblCity.Colname(4))=0
  End If
  frmSetting.Show
  tblCity.SelectCell(tblCity.ColName(0),lastcity)
End Sub
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Keypress and SelectionChanged.. robee9931 Questions & Help Needed 1 05-27-2008 04:08 PM
SelectionChanged problem skipper Questions & Help Needed 4 04-09-2008 02:26 PM
SelectionChanged work in desktop, but not in ppc?? laiyilam Questions & Help Needed 1 09-10-2007 01:52 PM
Listview and SelectionChanged magi6162 Questions & Help Needed 11 09-06-2007 10:02 AM
Showing a form in a SelectionChanged event specci48 Questions & Help Needed 3 05-18-2007 03:05 PM


All times are GMT. The time now is 03:33 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0