Question

I have assigned 2 ultracombobox which is databinded to a collection. But when I change the value of the combobox the collection is not getting reflected.

But when I change the value of the second combobox the changes made by the first combobox is getting reflected and the second is not.

//Code

'DataBinding Declaration

    Public Shared ObjLookupHeaderBindings As BindingSource = New BindingSource() 

'Binding Asignment

    ObjLookupHeaderBindings.DataSource = LookupHeadersCollection
    ultraGridBase.DataSource = ObjLookupHeaderBindings

'Collection Class Example code
Public Class LookupHeadersCollection

Public Event LookupSQLCommandChanged As EventHandler

 ''' <summary>
    ''' Get or set the SQL Query values
    ''' </summary>
    ''' <value></value>
    ''' <remarks></remarks>
    Public Property LookupSQLCommand() As String
        Get
            Return Me.m_sLookupSQLCommand
        End Get

        Set(ByVal value As String)
            Me.m_sLookupSQLCommand = value
            Me.m_bIsChanged = True
            RaiseEvent LookupSQLCommandChanged(Me, EventArgs.Empty)
        End Set

    End Property
End Class

'Add Binding into to controls
cmbSQLServer.DataBindings.Add(New Binding("Text", ObjLookupHeaderBindings, "LookupConnection", False))
cmbDatabaseName.DataBindings.Add(New Binding("Text", ObjLookupHeaderBindings, "LookupDatabaseName", False))
txtSQLCommand.DataBindings.Add(New Binding("Value", ObjLookupHeaderBindings, "LookupSQLCommand", False))


'I tried to the following ways, but its not working.
txtSQLCommand.DataBindings(O).ReadValue()
ObjLookupHeaderBindings.CurrencyManager.Refresh()

Where i'm going wrong?

Was it helpful?

Solution

Added UpdateMode of the DataSource then it worked fine.

//Code

cmbSQLServer.DataBindings.Add(New Binding("Text", Controller.ObjLookupHeaderBindings, "LookupConnection", False, DataSourceUpdateMode.OnPropertyChanged))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top