Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

StackOverFlow of ComboBox Sele

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gh - 21 Dec 2004 01:12 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.