ComponentOne Input for WinForms
Input for WinForms Task-Based Help / Navigating the C1DateEdit Control
In This Topic
    Navigating the C1DateEdit Control
    In This Topic

    When end-users select the C1DateEdit control, then press the Enter or Tab to move to another control or select another control with the mouse, the current date is automatically entered into the C1DateEdit control.

    To move to another control without the date being automatically entered, complete one of the following:

    Using the Designer:

    1. Create a new .NET project and place a C1DateEdit control and a C1TextBox control on your form.
    2. To show end-users that a control has an empty value, in the C1DateEdit.NullText property, enter “{Empty Value}”.

      If you ran the program at this point and selected the C1DateEdit control with either the keyboard or mouse, then try to select the C1TextBox control, today’s date would automatically be entered into the C1DateEditr field and you would be unable to leave that field blank.
       navigate_c1dateditcontrol             

      Notice that the cursor is in the C1TextBox but the current date remains in the C1DateEdit field.

    3. Using the Properties window, change the C1DateEdit1.DateTimeInput property to False and change the C1DateEdit1.EmptyAsNull property to True.
    4. Run the Program and click on the C1DateEdit control, then click on the C1TextBox.
      navigate_c1dateditcontrol   

    Notice that even after switching to the C1TextBox, the C1DateEdit field remains empty.

    Using the Code Editor:

    1. Create a new .NET project and in the Solution Explorer add a reference to the C1Input control.
    2. Add the following import statement to the code editor

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Imports C1.Win.C1Input
      

      To write code in C#

      C#
      Copy Code
      using C1.Win.C1Input;
      
    3. Add the C1DateEdit control and C1TextBox control to the Form_Load event.

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Dim X As New C1DateEdit
      Controls.Add(X)
      X.Location = New Point(50, 40)
      Dim Y As New C1TextBox
      Controls.Add(Y)
      Y.Location = New Point(100, 80)
      

      To write code in C#

      C#
      Copy Code
      C1DateEdit X = new C1DateEdit();
      Controls.Add(X);
      X.Location = new Point(50, 40);
      C1TextBox Y = new C1TextBox();
      Controls.Add(Y);
      Y.Location = new Point(100, 80);
      
    4. To show end-users that the control has an empty value, add the following code to the C1DateEdit entry.

      To write code in Visual Basic

      Visual Basic
      Copy Code
      X.NullText = "{Empty Value}"
      

      To write code in C#

      C#
      Copy Code
      X.NullText = "{Empty Value}";
      

      If you ran the program at this point and selected the C1DateEdit control with either the keyboard or mouse, then try to select the C1TextBox control, today’s date would automatically be entered into the C1DateEdit field and you would be unable to leave that field blank.

      navigate_c1dateditcontrol
             
    5. To preserve the “Empty Value” in the C1DateEdit field even after switching to another control, add the following code to the C1DateEdit entry.

      To write code in Visual Basic

      Visual Basic
      Copy Code
      X.DateTimeInput = False
      X.EmptyAsNull = False
      

      To write code in C#

      C#
      Copy Code
      X.DateTimeInput = False;
      X.EmptyAsNull = False;
      
    6. Run the Program and click on C1DateEdit control, then click on the C1TextBox.
       navigation_c1dateditcontrol  

    Notice that even after switching to the C1TextBox, the C1DateEdit field remains empty.

    See Also