Welcome to the Xceed Community | Help
Community Search  

DatePicker's Calendar defult selection

Sort Posts: Previous Next
  •  07-14-2008, 2:58 PM Post no. 13544

    DatePicker's Calendar defult selection

    Hi!

    I'm using DatePicker. By default the SelectedDate value is empty. When calendar's popup is shown - displayed date is "Today". Is it possible to move selection to another date?? For example to 4.12.1961 ??

     (without selecting date in calendar - SelectedDate should remain null)

  •  08-05-2008, 12:11 PM Post no. 13896 in reply to 13544

    Re: DatePicker's Calendar defult selection

    You cannot set the calendar to a specific date without setting SelectedDate.  However, you can set the FirstMonth property, so at least you have the right month shown when the calendar is dropped down.

    e.g.: 

    private void Form1_Load( object sender, EventArgs e )

    {

        winDatePicker1.ValueChanged += new EventHandler( winDatePicker1_ValueChanged );

        winDatePicker1.DroppedDownChanged += new EventHandler( winDatePicker1_DroppedDownChanged );

    }

    void winDatePicker1_DroppedDownChanged( object sender, EventArgs e )

    {

        WinDatePicker winDatePicker = sender as WinDatePicker;

        if( ( winDatePicker.Value == winDatePicker1.NullDate ) && ( winDatePicker1.DroppedDown ) )

        {

            winDatePicker1.DropDownControl.FirstMonth = new DateTime( 2008, 3, 17 );

        }

    }

    void winDatePicker1_ValueChanged( object sender, EventArgs e )

    {

        winDatePicker1.DroppedDownChanged -= new EventHandler( winDatePicker1_DroppedDownChanged );

    }

     


    André
    Software Developer and Tech Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.