Пример #1
0
        private void lstAddresses_EditClick(object sender, EventArgs e)
        {
            var item = lstAddresses.SelectedItems.Cast <StreetAddress>().FirstOrDefault();

            if (item != null)
            {
                var copy = item.Duplicate();
                using (var dlg = new EditStreetAddressDialog(copy))
                {
                    dlg.Text = "Edit Address";
                    if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                    {
                        var index = addresses.IndexOf(item);
                        addresses[index] = copy;
                        addresses.ResetItem(index);
                    }
                }
            }
        }
Пример #2
0
        private void lstAddresses_AddClick(object sender, EventArgs e)
        {
            var address = new StreetAddress
            {
                City    = "West Allis",
                Line1   = "1111 South Fake Street",
                Line2   = "",
                State   = USState.WI,
                Type    = AddressType.Other,
                ZipCode = 12345,
            };

            using (var dlg = new EditStreetAddressDialog(address))
            {
                dlg.Text = "Add Address";
                if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    addresses.Add(address);
                }
            }
        }