Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combobox change value after focus lost

Status
Not open for further replies.

ErnstJan

Programmer
Nov 10, 2002
114
0
0
NL
Hi,

I have a strange problem that I can't seem to solve.
Using VB.net 2005
On a form I have a comboboxen that is populated thru datatables.
One combobox hold names of relations of the company
Valuemember is set to ID column (relatieID)
Displaymember is set to the relationname (RelatieNaam).
After selecting a relation a combobox holding contacts will be filled with the contacts of the selected relation.
There is no problem with this. All works fine.

But......
Now in de relation table there are relations with similair names but diffrent ID's.
Should be no problem but when a duplicated relation is selected it fills the contacts always with the same contacts.
Stepped thru code and I found out that the moment you leave the combobox its selectedvalue is changed but no code is run to do that. It goes into the LostFocus code before running that the selected value has been changed already

Is there someone familiar with this problem or knows a clean solution to it.

Thanks in advance.

Here is code that is used by combobox for selecting the relation
Code:
    Private Sub RelatieGewijzigd(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comboRelatie.SelectionChangeCommitted, comboRelatie.SelectedValueChanged

        'Controleren of formulier geladen wordt
        If isLoading = False And isVernieuwen = False Then
            'Controleren dat keuze niet leeg is
            If IsNothing(comboRelatie.SelectedValue) Then
                'Instellen dat er geen keuze is gemaakt
                varRelatie = 0
            Else
                'Keuze overnemen
                varRelatie = comboRelatie.SelectedValue
            End If

            'Keuzelijst contactpersonen vernieuwen
            OphalenGegevens(WelkeGegevens.Contactpersonen)
            'Keuze contactpersoon wissen
            comboContactpersoon.SelectedValue = 0
            'Instellen dat er wijzigingen zijn geweest  
            isGewijzigd = True
        End If

    End Sub

    Private Sub comboRelatie_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles comboRelatie.LostFocus

        'Controleren of de selectie
        If IsNothing(comboRelatie.SelectedValue) Then
            If Not comboRelatie.Text = String.Empty Then
                'Gegevens controleren
                Relatie.Check(comboRelatie, varData, "Relaties")
                'Contact personen vernieuwen
                OphalenGegevens(WelkeGegevens.Contactpersonen)
            End If
        End If

    End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top