1
솔루션
이 내가 생각 해낸 것입니다 :DataBound ComboBox의 DisplayMember를 사용자 정의 할 수 있습니까?
Public Class IndexedDropDownItem
Private _KeyCode, _Display As String
Public Property KeyCode() As String
Get
Return _KeyCode
End Get
Set(ByVal value As String)
_KeyCode = value
End Set
End Property
Public Property Display() As String
Get
Return _Display
End Get
Set(ByVal value As String)
_Display = value
End Set
End Property
Sub New(ByVal KeyIndex As String, ByVal ItemDisplay As String)
KeyCode = KeyIndex
Display = ItemDisplay
End Sub
Public Overrides Function ToString() As String
Return String.Format("{0} - {1}", KeyCode, Display)
End Function
End Class
구현 :
With myDropDown
Dim oItem As IndexedDropDownItem = Nothing
For Each dr As Data.DataRow In oTemp.Rows
oItem = New IndexedDropDownItem(dr.Item("key_code"), _
dr.Item("descript"))
.Items.Add(oItem)
oItem = Nothing
Next
End With
조작 :
Dim _KeyCode, _Display As String
With CType(dataPathComboBox.SelectedItem, IndexedDropDownItem)
_KeyCode = .KeyCode
_Display = .Display
End With
나는이 사람을 도움이되기를 바랍니다! - 내가 설정 한 값을 유지하면서, "Descript를 key_code"나는 DisplayMember 쇼를 가질 수 있기를 원하는
With myComboBox
.DataSource = myDataTable
.DisplayMember = "descript"
.ValueMember = "key_code"
End With
:
나는 DataTable을에서 채워지는 콤보가 있습니다.
이것도 가능합니까? 감사합니다
예를 들어 설명해 주시겠습니까? 나는 네가하는 말을 이해한다고 생각하지만 나는 확실히하고 싶다. – Anders
해결책을 찾은 것처럼 보입니다! 그게 내가하고있는 것에 관한 이야기입니다. –
+ 올바른 방향으로 밀어 주셔서 감사합니다. – Anders