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.


SelectionChanged problem


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-09-2008, 11:46 AM
Junior Member
 
Join Date: Dec 2007
Posts: 40
Default SelectionChanged problem

I noticed a strange behaviour on combobox related to the SelectionChanged event. I'll try to explain what happens. I have 2 comboboxes: the first one (cmbBrand) is filled with BRAND values from a single column table, the second combobox (cmbModel) is filled with MODELS values form a two columns (BRAND, MODELS) table. At runtime, before entering the input routine, I call the Cleanup routine containing the following instructions

cmbBrand.SelectedIndex=-1
cmbModel.SelectedIndex=-1

During input, the program fires a cmbBrand_SelectionChanged (Index, Value) event that filters the two colum table based on the selected BRAND, and then cleanups and reloads the cmbModel in order to show only the Models of the selected Brand.

After input, the data are saved to a SQL table and then the program calls again the above Cleanup routine.

At that point the program raises an "Object reference not set to an instance of an object" and points to the cmbBrand.SelectedIndex=-1 instruction.

Commenting out the entire SelectionChanged routine, the Cleanup routine is called again and again without errors.

Here is the routine

Sub cmbBrand_SelectionChanged (Index, Value)
tblModel.Filter("MODEL_BRAND = " & SurrLastItem(Value))
cmbModel.SelectedIndex = -1
cmbModel.Clear
For k=0 To tblModel.RowCount-1
cmbModel.Add(tblModel.Cell("MODEL_NAME",k))
Next k
tblModel.Filter("")
End Sub

SurrLastItem returns a string enclosed between singles quotes.

Is anyone here that could give me please any help?

Many thanks
Mimmo
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 12:51 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

Where is the "cmbBrand.SelectedIndex = -1" line?
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 01:04 PM
Junior Member
 
Join Date: Dec 2007
Posts: 40
Default

Hello Erel,
both the instructions are in the CleanFields routine togheter with other field cleanup instructions

Sub CleanFields
txtID.Text = ""
chkJava14.Checked = False
....
cmbModel.SelectedIndex = -1
cmbBrand.SelectedIndex = -1
....
txtMACAddress.Text = ""
End Sub

The routine is called 2 times: before accepting the input and after saving the record. In the meantime (during the input), the cmbBrand_SelectionChanged is fired

Many thanks for your help
Mimmo
Reply With Quote
  #4 (permalink)  
Old 04-09-2008, 01:15 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

There is a problem with setting the index to -1 and catching the SelectionChanged event.
It will be fixed in the next version.
You can add a blank value as the first value or you can use cmbBrand.Text = "".
Reply With Quote
  #5 (permalink)  
Old 04-09-2008, 02:26 PM
Junior Member
 
Join Date: Dec 2007
Posts: 40
Default

Many thanks Erel,

I fixed it changing only the combo raising the event and it works (on the desktop). I'll try on device.

Please, feel free to move the thread to the appropriate section.

Many thanks again
Mimmo
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
table: SelectionChanged() and SelectedRow stbi Questions & Help Needed 7 12-21-2007 04:14 AM
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:52 AM.


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