Hi,
I created a class that has three string members, ShortCut,
ClientCode and ClientName. I used a ArrayList to store the class instances
and binded these fields to a 3 combo boxes with the following code.
this.orderTicket1.CboClientSC.DisplayMember="Shortcut";
this.orderTicket1.CboClientSC.ValueMember="Code";
this.orderTicket1.CboClientSC.DataSource=this.shortcutList;
this.orderTicket1.CboClientCode.DisplayMember="Code";
this.orderTicket1.CboClientCode.ValueMember="Code";
this.orderTicket1.CboClientCode.DataSource=this.clientCodeList;
this.orderTicket1.CboClientName.DisplayMember="EnglishName";
this.orderTicket1.CboClientName.ValueMember="Code";
this.orderTicket1.CboClientName.DataSource=this.clientEngNameList;
I also added some interactions among these controls such that once I
changed one of combo boxes, the other boxes can changed accordingly. I
captured event SelectedValueChanged of three controls, and when I tried to
change the combox control of the ClientCode, it threw a stack overflow
exception. The below code that deals with the combo box changes after I
capture the SelectedValueChanged event,
if(currSelectClient.Shortcut!=null)
{
this.orderTicket1.CboClientSC.SelectedItem=currSelectClient.Shortcut;
}
else
{
this.orderTicket1.CboClientSC.SelectedIndex=0;
}
if(currSelectClient.Code!=null)
{
this.orderTicket1.CboClientCode.SelectedItem=currSelectClient.Code;
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//this causes the stackoverflowexception
}
else
{
this.orderTicket1.CboClientCode.SelectedIndex=0;
}
if(currSelectClient.EnglishName!=null)
{
this.orderTicket1.CboClientName.SelectedItem=currSelectClient.EnglishName;
}
else
{
this.orderTicket1.CboClientName.SelectedIndex=0;
}
Jeff Gaines - 21 Dec 2004 09:40 GMT
> Hi,
>
[quoted text clipped - 19 lines]
> threw a stack overflow exception. The below code that deals with the
> combo box changes after I capture the SelectedValueChanged event,
Do you have a situation when cbo1 changes triggering a change in cbo2
which triggers a change in cbo3 which in turn triggers a change in cbo1
etc. thus creating an infinite loop?
When I do something like this I have a global bool flag which gets set
when, say, cbo1 changes and is checked by the change events in cbo2 and
cbo3. It is reset after cbo1 has finished its changes.

Signature
Jeff Gaines
Posted with XanaNews 1.16.5.2