Example #1
0
        public void DateListBoxDemo()
        {
            // Manage DateListBox custom control from the code behind
            DateListBox dlb = new DateListBox();

            dlb.DisplayDateFormat = "MM/dd/yyyy";

            // Add date/time items to the list
            dlb.AddDateItem(new DateTime(2007, 7, 5));
            dlb.AddDateItem(new DateTime(2007, 7, 5, 9, 0, 0));
            dlb.AddDateItems(new DateTime[] { DateTime.Today, DateTime.Now, DateTime.Now.AddDays(2) });
            dlb.AddDateItems(new DateTime(2007, 7, 6), new DateTime(2007, 7, 12));

            // Remove date/time items from the list
            // The delCount will be 1 after the next operation
            int delCount = dlb.RemoveDateItem(new DateTime(2007, 7, 5));

            // The delCount will be 0 after the next operation
            delCount = dlb.RemoveDateItem(new DateTime(2007, 7, 5));

            // Remove several items
            delCount = dlb.RemoveDateItems(new DateTime[] { DateTime.Today, DateTime.Now });
            delCount = dlb.RemoveDateItems(new DateTime(2007, 7, 6), new DateTime(2007, 7, 12));

            //Perform selection
            dlb.Items[0].Selected = true;

            // Get the first selected item
            DateTime selItem = dlb.SelectedDate;

            // Get the selected items
            DateTime[] selItems = dlb.SelectedDates;
        }
Example #2
0
 public void TearDown()
 {
     dlb = null;
 }
Example #3
0
 public void SetUp()
 {
     dlb = new DateListBox();
     dlb.DisplayDateFormat = DisplayDateFormat1;
 }