private void Form1_Load(object sender, EventArgs e) { // Create and populate the list of DemoCustomer objects // which will supply data to the DataGridView. BindingList<DemoCustomer> customerList = new BindingList<DemoCustomer>(); customerList.Add(DemoCustomer.CreateNewCustomer()); customerList.Add(DemoCustomer.CreateNewCustomer()); customerList.Add(DemoCustomer.CreateNewCustomer()); // Bind the list to the BindingSource. this.customersBindingSource.DataSource = customerList; // Attach the BindingSource to the DataGridView. this.customersDataGridView.DataSource = this.customersBindingSource; }
static void Main(string[] args) { ArrayList customerList = new ArrayList(); customerList.AddRange(new DemoCustomer[] { new DemoCustomer(), new DemoCustomer(), new DemoCustomer() }); customerList.Add(DemoCustomer.CreateNewCustomer()); Console.WriteLine("Items in List: {0}", customerList.Count); // Print out current values. foreach (DemoCustomer c in customerList) { Console.WriteLine("ID: {0}", c.ID); Console.WriteLine("CustomerName: {0}", c.CustomerName); Console.WriteLine("PhoneNumber: {0}", c.PhoneNumber); Console.WriteLine("\n"); } // // create the delegate that the Timer will call TimerCallback tc = new TimerCallback(CheckTime); // create a Timer that runs twice a second, starting in one second Timer t = new Timer(tc, "Hi", 1000, 500); // Wait for user input Console.WriteLine("Press Enter to exit"); int i = Console.Read(); // clean up the resources t.Dispose(); t = null; }
static void Main(string[] args) { ArrayList customerList = new ArrayList(); customerList.AddRange(new DemoCustomer[] { new DemoCustomer(), new DemoCustomer(), new DemoCustomer() }); customerList.Add(DemoCustomer.CreateNewCustomer()); Console.WriteLine("Items in List: {0}", customerList.Count); BinarySerialize(customerList); ArrayList binaryPeople = BinaryDeserialize(); Console.WriteLine("Binary people:"); foreach (string s in binaryPeople) { Console.WriteLine("\t" + s); } }
// </snippet7> // <snippet8> // This event handler provides custom item-creation behavior. void customersBindingSource_AddingNew( object sender, AddingNewEventArgs e) { e.NewObject = DemoCustomer.CreateNewCustomer(); }