vb.net-数据绑定组合框不允许将选项卡移开 [英] vb.net - data bound combobox not allowing tab away
问题描述
我有一个ComboBox,它是绑定到对象属性的数据. ComboBox包含我生成的Enum值和描述的列表,如下所示:
I have a ComboBox that is data bound to a property of an object. The ComboBox contains a list of Enum values and descriptions which I have generated as follows:
Public Class Enumeration
#Region "Enumeration handling mothods"
Public Shared Function GetList(ByVal Enumerator As Type) As Enumeration.List
Dim items As New Enumeration.List
Dim values() As Integer = System.Enum.GetValues(Enumerator)
For Each enumItemId As Integer In values
Dim enumItem As New Item(enumItemId, System.Enum.GetName(Enumerator, enumItemId))
items.Add(enumItem)
Next
Return items
End Function
Public Class Item
Private _iId As Integer
Public ReadOnly Property Id() As Integer
Get
Return _iId
End Get
End Property
Private _sDescription As String
Public ReadOnly Property Description() As String
Get
Return _sDescription
End Get
End Property
Public Sub New(ByVal EnumId As Integer, ByVal EnumDescription As String)
_iId = EnumId
_sDescription = EnumDescription
End Sub
End Class
Public Class List
Inherits List(Of Enumeration.Item)
Default Public Shadows Property Item(ByVal index As Integer) As Item
Get
Return MyBase.Item(index)
End Get
Set(ByVal value As Item)
MyBase.Item(index) = value
End Set
End Property
Public Sub New()
MyBase.New()
End Sub
Public Shadows Sub Add(ByVal EnumItem As Item)
MyBase.Add(EnumItem)
End Sub
End Class
#End Region
End Class
和我的枚举定义如下
and my Enum is defined as follows
Public Enum Statuses
Unspecified = 0
Active = 1
OutOfService = 10
Sold = 50
Scrapped = 99
End Enum
ComboBox绑定的
The
SelectedValue
属性发送到myOject.Status属性
在表单加载"事件中
property of the ComboBox binding is sent to the myOject.Status property
In the Form Load event
myBindingSource.DataSource = _oMyObject
statusComboBox.DataSource = Enumeration.GetList(GetType(MyObject.Statuses))
我可以选择任何雕像,但不会让我离开组合框.如果删除绑定,则comboBox会按预期运行,除非对象属性值未更新.
任何帮助,不胜感激.
谢谢
I can select any of the statues, but it will not let me leave the ComboBox. If I remove the binding then the comboBox operates as expected, except then the object property value is not updated.
Any help greatly appreciated.
Thanks
推荐答案
您是否为组合框或绑定源处理了任何事件?
例如,如果您已经处理了组合的Validating事件,并且Cancel设置为true,那么只有输入有效的内容,您才能进入下一个控件.
Do you have any events handled for the combo box or the binding source?
For example if you would have handled the Validating event for the combo and the Cancel is set to true then you wouldn''t be able to get to the next control until you have a valid entry.
这篇关于vb.net-数据绑定组合框不允许将选项卡移开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!