M
Martin Smith
Hi! I'm feeling the burn of .NET; Still getting used to it
I'm trying to populate a combo box with instances of a class:
Public Class Shortcut
Private Name As String
Private RealLocation As String
Public Sub New()
Me.Name = "unknown"
Me.RealLocation = "unknown"
End Sub
Public Sub New(ByVal Name As String, ByVal Path As String)
Me.Name = Name
Me.RealLocation = Path
End Sub
Public Function getName() As String
Return (Me.Name)
End Function
Public Function getRealLocation() As String
Return (Me.RealLocation)
End Function
Public Overrides Function toString() As String
Return (Me.Name)
End Function
End Class
My problem is the following code:
With cmb
.ValueMember = "getRealLocation"
.DisplayMember = "toString"
.Items.Add(New Shortcut("Label1", "Full Path1"))
.Items.Add(New Shortcut("Label2", "Full Path 2"))
.Items.Add(New Shortcut("Label3", "Full Path 3"))
End With
When the combo list isn't activated, the combo box shows the results of the
toString function, for the specific instance that is selected. However, when
I click the drop-down button, it shows a list of blank entries. Selecting a
blank entry again shows the results of the toString function of the instance
I apparently selected.
How can I make each entry have a value whent he combobox drop-down list is
showing, not just once a specific item in the list is selected. It's hard to
make choices when there's only blank options =/.
Thanks again!
I'm trying to populate a combo box with instances of a class:
Public Class Shortcut
Private Name As String
Private RealLocation As String
Public Sub New()
Me.Name = "unknown"
Me.RealLocation = "unknown"
End Sub
Public Sub New(ByVal Name As String, ByVal Path As String)
Me.Name = Name
Me.RealLocation = Path
End Sub
Public Function getName() As String
Return (Me.Name)
End Function
Public Function getRealLocation() As String
Return (Me.RealLocation)
End Function
Public Overrides Function toString() As String
Return (Me.Name)
End Function
End Class
My problem is the following code:
With cmb
.ValueMember = "getRealLocation"
.DisplayMember = "toString"
.Items.Add(New Shortcut("Label1", "Full Path1"))
.Items.Add(New Shortcut("Label2", "Full Path 2"))
.Items.Add(New Shortcut("Label3", "Full Path 3"))
End With
When the combo list isn't activated, the combo box shows the results of the
toString function, for the specific instance that is selected. However, when
I click the drop-down button, it shows a list of blank entries. Selecting a
blank entry again shows the results of the toString function of the instance
I apparently selected.
How can I make each entry have a value whent he combobox drop-down list is
showing, not just once a specific item in the list is selected. It's hard to
make choices when there's only blank options =/.
Thanks again!