?
Solved

VB.net Events and Databinding

Posted on 2009-07-06
6
Medium Priority
?
203 Views
Last Modified: 2012-05-07
I've posted my code below.  I have 2 combo boxes (cbo1 and cbo2)

When the user selects a value from cbo1, and changes focus, I want to set the value of cbo2 based on the selected value of cbo1.  

The fetchList call works fine, it returns the selected list.

Here is the problem.  When I select an item from cbo1, and then cause it to lose focus, the below function is called, BUT cbo2 is blank.  If i select the same item again (from cbo1) and lose focus again, cbo2 is then filled properly.

Can anyone point out what I'm doing wrong?


Private Sub cbo1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbo1.LostFocus
        If cbo1.SelectedValue Is Nothing Then Exit Sub
            cbo2.DisplayMember = "DisplayString"
            cbo2.ValueMember = "Value"
            cbo2.DataSource = myClass.fetchList(cbo1.SelectedValue)
  
    End Sub

Open in new window

0
Comment
Question by:BobBarker_99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 24789557
set breakpoint at line: If cbo1.SelectedValue Is Nothing Then Exit Sub
and see the value of cbo1.SelectedValue  when the first time it is not being populated...
Could be that value is being not set for some reason ...
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 24790732
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24793769
I think using the SelectedIndexChanged event may help.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:BobBarker_99
ID: 24793795
I have tried setting a breakpoint.  The selected value is as expected, but the second combo box does not populate.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 24793887
Are you sure the fetchlist does return results? Set a breakpoint in that function to see what it is returning.
0
 

Author Closing Comment

by:BobBarker_99
ID: 31600373
Found it.  It was returing results, but different results the first and second time through.  Tracked it down, the cbo1.selectedValue wasnt what I expected teh first time through.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month8 days, 22 hours left to enroll

764 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