Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created two classes: Person and Expense in which an expense might have at most a reposible person.

VB
Public Class Person
  ...
End Class

Public Class Expense
  Private m_descr  As String 'Describe the expense
  Private m_amount As Double 'Amount expensed
  Private m_person As Person 'A person who is responsible for an expense

  Public Property Description() As Double ... End Property
  Public Property Amount() As Double ... End Property
  Public Property Person() As Person ... End Property
  ...
End Class


If I want to bind the property Parent of an expense to a Combox with dropdonw items bound to a list of Persons, How can I do (in VB.Net) in order to change the responsible person of this expense when a person in the dropdown of this combobox was chosen?
Posted
Updated 5-Aug-11 18:13pm
v2

1 solution

If you want to bind combobox to your class, your class needs to implement IList[^] Interface.
This links would be helpful too:
How to bind a windows forms combobox control to data[^]
IList(of T)[^]

If you want to change Person for Expense, change the Person property:
VB
Public Property Person(ByVal _person As Person) As Person
    Get
        Return m_Person
    End Get
    Set(ByVal _person As Person)
        m_Person = _person
    End Set
End Property
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900