I created custom ComboBox control and want to bind custom property "ActiveValue" to a DataSet. I do it in the way:
cboMyComboBox.DataBindings.Add(New System.Windows.Forms.Binding("ActiveValue", Me.dstDetails, "Table.CBOVALUE", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged, ""))
...
Public Property ActiveValue As String
Get
Return _activeValue
End Get
Set(value As String)
If _activeValue <> value Then
_activeValue = value
Me.Text = _activeValue
End If
End Set
End Property
It retrieves value from DataSet, but it is unable to update. It doesn't matter what value I choose it simply is not updated. This property is simple text field. Tried to implement INotifyPropertyChanged on my derived ComboBox class, but it not helped. Could someone tell me where is the problem? Thanks
UPDATE: found a bug in my class but Rex provided databinding write methods is also helpful, thanks for your time.
Not sure why as I cannot see your full implementation, but if you really want to force the databinding to write value back to object, try DataBinding.WriteValue(), so in your ComboBox class, do this at appropriate place (probably at some text changed event handler):
theDataBinding = Me.DataBindings(theIndex) ' you may find the binding by the bound field name
theDataBinding.WriteValue()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.