Esempio n. 1
0
        private void InitialCarList()
        {
            List <Car> infos = new List <Car>()
            {
                new Car()
                {
                    AutoMark = "reventon", Name = "reventon", TopSpeed = "200", Year = "1990"
                },
                new Car()
                {
                    AutoMark = "murcielago", Name = "murcielago", TopSpeed = "250", Year = "1998"
                },
                new Car()
                {
                    AutoMark = "gallardo", Name = "gallardo", TopSpeed = "300", Year = "2002"
                },
                new Car()
                {
                    AutoMark = "diablo", Name = "diablo", TopSpeed = "350", Year = "2011"
                },
                new Car()
                {
                    AutoMark = "Aodi", Name = "Aodi", TopSpeed = "500", Year = "2020"
                }
            };

            foreach (Car item in infos)
            {
                CarListViewItem viewItem = new CarListViewItem();
                viewItem.Car = item;
                this.listBoxCars.Items.Add(viewItem);
            }
        }
Esempio n. 2
0
        private void listBoxCars_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            CarListViewItem viewItem = e.AddedItems[0] as CarListViewItem;

            if (viewItem != null)
            {
                carDetailView1.Car = viewItem.Car;
            }
        }