You must Sign In to post a response.
  • Category: Visual Studio

    DateTime Picker Tool

    Dear All,

    I have DateTimePicker Tool in my application.
    Need to clear the DateTimePicker display date.

    User can able to change their date in that tool.
    Give me solutions.



    Regards,
    Ramkumar G.R
  • #754740
    You can set the current date as the selected date.

    and to clear the date use script



    <script type="text/javascript">
    function clearDatePicker()
    {
    var datepicker = $find("<%= DatePicker1.ClientID %>");
    datepicker.clear();
    }
    </script>

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #754750
    Hi Ramkumar,

    You need "claer" button inside datePicker widgat? or what?

    That means while user enter the date it will disply date and again if he click the clear button it will clear the date. again u can set date.

    other wise u use this code for clearing date field:
    $.datepicker._clearDate($("#<%=datefield.ClientID%>"));

    hope u understand..





    Thnaks,
    chitaranjan

  • #754767
    Sets your format of the date and time displayed in the control under Namespace System.Windows.Forms syntax is : public DateTimePickerFormat Format { get; set; }
    Example

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;

    namespace TimePickerApplication
    {
    public class Form1 : Form
    {
    public Form1()
    {
    InitializeTimePicker();
    }
    private DateTimePicker timePicker;

    private void InitializeTimePicker()
    {
    timePicker = new DateTimePicker();
    timePicker.Format = DateTimePickerFormat.Time;
    timePicker.ShowUpDown = true;
    timePicker.Location = new Point(10, 10);
    timePicker.Width = 100;
    Controls.Add(timePicker);
    }
    [STAThread]
    static void Main()
    {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
    }

    }
    }


  • Sign In to post your comments