Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Objective-C list Homework , +
I have a winforms application which consists of a Van class and a delivery class.
 
Van class:
 
public class Van
    {
        private string VanNumber;
        public string vanNumber
        {
            get { return VanNumber; }
            set { VanNumber = value; }
        }
 
        public List<Delivery> Deliveries = new List<Delivery>();
 
        public override string ToString()
        {
            return VanNumber.ToString();
        }
 

    }
 

Delivery class:
 
public class Delivery
    {
        private string CustomerName;
        public string customerName
        {
            get { return CustomerName; }
            set { CustomerName = value; }
        }
        private string CustomerAddress;
        public string customerAddress
        {
            get { return CustomerAddress; }
            set { CustomerAddress = value; }
        }
        private DateTime ArrivalTime;
        public DateTime arrivalTime
        {
            get { return ArrivalTime; }
            set { ArrivalTime = value; }
        }
 
        public override string ToString()
        {
            return CustomerName + " " + CustomerAddress + " " + ArrivalTime.ToString();
        }
    }
 

 

 

I need to be able to store a list of vans, which I have done successfully using a combobox. What I now want to do, is add an instance of my delivery class to the list within a van stored in the combobox. I have a button on my main form(contains combobox) which links to form for adding deliveries. Ideally, i'd like to be able to highlight a van in the combobox and add a delivery via the 'add delivery' form. I just have no idea how to do this!
 
Any help is greatly appreciated!!
Posted 27-Nov-12 23:45pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I assume you have a List bound to ComboBox called, say, VanComboBox - the command you are looking for is:
 
((Van)VanComboBox.SelectedItem).Deliveries.Add(DeliveryItem)
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 28 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100