[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

one listbox controls population of another listbox

Posted on 2006-03-28
2
Medium Priority
?
184 Views
Last Modified: 2010-04-16
I apologize in advance if this has already been asked, but I couldn't find a solution.

I have two listboxes.  When I click on listbox1, it controls what is placed in listbox2.  I then want to select something from listbox2 and put both selections in two textboxes.

My problem is when I select from listbox1, it populates listbox2 and then listbox2, thinking it's index has been changed (it has, just not manually) populates the two textboxes. The index on listbox2 is set to 0, but that is a valid selection.

How can I tell if the listbox2 item has been manually selected or is just being populated?
0
Comment
Question by:rmmarsh
2 Comments
 
LVL 6

Accepted Solution

by:
e1v earned 2000 total points
ID: 16312704
You could remove the eventhandler for listbox2.SelectedIndexChanged in the code for populating listbox2 and re-add it when you're done.

Like this:

listBox2.SelectedIndexChanged -= listBox2_SelectedIndexChanged;
//populate listbox2 and selectindex=0
listBox2.SelectedIndexChanged += new System.EventHandler(listBox2_SelectedIndexChanged);
0
 

Author Comment

by:rmmarsh
ID: 16313343
Thank you, that did it...
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Integration Management Part 2
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question