Home Forums WinForms controls Other WinForms controls DatePicker’s Calendar defult selection

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18479 |

    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)

    Imported from legacy forums. Posted by Youri (had 2580 views)

    User (Old forums)
    Member
    Post count: 23064

    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 );

    }

     

    Imported from legacy forums. Posted by André (had 3118 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.