Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2010 Combobox bound to an objectdatasource reverts to empty string on lost focus

$
0
0
I have a combobox that is bound to a objectdatasource. The combobox is used as a lookup.

My problem is everytime the combobox looses its focus it reverts to an empty string. The selection disappears (text.property will result to empty string). This is very weird.

Any ideas?

My Code Below:

Code:

Public Class frmUsers_AddEdit   

    Private newUser As Users
    Private usertypeList As List(Of UserType)

    Private Sub LoadComboboxes()
        Try
            usertypeList = UserTypeDB.GetUserTypeList
            UserTypeComboBox.DataSource = usertypeList

        Catch ex As Exception
            MessageBox.Show(ex.Message, ex.GetType.ToString)
        End Try

    End Sub

    Private Sub frmUsers_AddEdit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.LoadComboboxes()
        UsersBindingSource.Add(newUser)

    End Sub

 end class

 Databindings of my UserTypeComboBox:

    UserTypeComboBox.DataSource = UserTypeBindingSource
    UserTypeComboBox.DisplayMember = UserType
    UserTypeComboBox.ValueMember = UserTypeID
    UserTypeComboBox.SelectedValue =  UsersBindingSource - UserTypeID


Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>