Lösung
ist, was ich kam mit:Kann das DisplayMember einer DataBound ComboBox angepasst werden? Diese
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
Umsetzung:
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
Manipulation:
Dim _KeyCode, _Display As String
With CType(dataPathComboBox.SelectedItem, IndexedDropDownItem)
_KeyCode = .KeyCode
_Display = .Display
End With
Ich hoffe, das jemand helfen wird!
Ich habe eine ComboBox, die aus einer Datentabelle bevölkert:
With myComboBox
.DataSource = myDataTable
.DisplayMember = "descript"
.ValueMember = "key_code"
End With
Ich möchte die Display Show zu haben, um der Lage sein, „key_code - descript“, während der Wert beibehalten ich gesetzt haben.
Ist das überhaupt möglich? Danke
Könnten Sie mich auf ein Beispiel oder ein Beispiel hinweisen? Ich glaube, ich verstehe, was du sagst, aber ich will sicher sein. – Anders
Sieht so aus, als hättest du selbst eine Lösung gefunden! Das entspricht meinen Vorstellungen. –
+ Punkte für Sie Herr, danke für den Schub in die richtige Richtung :) – Anders