2

我已经分配了 2 个超组合框,它被数据绑定到一个集合。但是当我更改组合框的值时,集合没有得到反映。

但是,当我更改第二个组合框的值时,第一个组合框所做的更改会得到反映,而第二个则不会。

//代码

'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()

我哪里错了?

4

1 回答 1

2

添加UpdateModeDataSource然后它工作正常。

//代码

cmbSQLServer.DataBindings.Add(New Binding("Text", Controller.ObjLookupHeaderBindings, "LookupConnection", False, DataSourceUpdateMode.OnPropertyChanged))
于 2013-06-07T06:07:14.373 回答