Two ComboBoxes, Relation, SelectedIndexChanged event

P

PeterZ

SCENARIO
--------
I have a Win forms project (C#), two comboboxes databound to two
tables linked with a relation (parent child). Selecting a value from
Combo1 filters out the approprate values in combo2 - no rocket sience
here - all works fine.

I capture the SelectedIndexChanged event of Combo2 to perform some
validation on the form, ie. enable/disable some buttons, etc.. All
this works fine.... BUT.....


THE PROBLEM
-----------
The abovementioned event is only triggered when Combo2 is interected
with physically by the user (ie. mouse click). If however the values
in Combo2 are refreshed as a result of the user selecting a different
item in Combo1, the SelectedIndexChanged event is not triggered on
Combo2! Why the hell not?


FAILED ATTEMPTS TO GET AROUND THE PROBLEM
-----------------------------------------
Tried capturing the SelectedValueChanged, TextChanged,
CollectionChanged events on Combo2 but none are triggered.

Tried capturing the SelectedIndexChanged event on Combo1 (parent), but
by doing this the databindings haven't had time to refresh the values
in Combo2 (child), they are qued after the event I think. So I can't
run my validation routine with 'old' values in Combo2 which are out of
synch with Combo1.


I can't supply any code as the DataSet/DataAdaper/DataRelation have
all been cofigured through the IDE.


Any ideas from ADO gurus?
Surely someone has come accross this before?

Cheers,
Peter Z
 
R

Rajesh Patel

No idea right now. but, you can try workaround as below.

try to add following statement into combo1 selectedindexchange event.

combo2_selectedindexchanged(combo2, new system.eventargs)

Hope this should work

Rajesh Patel
 
P

PeterZ

try to add following statement into combo1 selectedindexchange event.
combo2_selectedindexchanged(combo2, new system.eventargs)

Thanks for the suggestion Rajesh, this forced the event to be
triggered on Combo2, but the problem still lies with the fact that
Combo2 hasn't been refreshed with new values by the databingings
(related to Combo1).

Is there a way to force a control to refresh its databindings which
are based on a relation? I tried the following but none worked:

Combo1.Refresh();
Application.DoEvents();

Cheers.
Peter Z
 
R

Rajesh Patel

Right now, no clue.

but, for the time being use filter on combo2's datatable. I will see it
later.

Rajesh Patel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top