Version

IsDateValid Property

Returns whether the control's current value represents a valid date
Syntax
'Declaration
 
Public ReadOnly Property IsDateValid As Boolean
public bool IsDateValid {get;}
Remarks

The IsDateValid property can be used to determine if the date to which the control's DateTime property is currently set is valid, i.e., falls within the range specified by the MinDate and MaxDate properties.

The IsDateValid property is available only at runtime.

Example
This example checks the validity of the control's value in the BeforeDropDown event handler, and cancels the event if it is not valid.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinEditors

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        '	Set focus to the UltraDateTimeEditor
        Me.UltraDateTimeEditor1.Focus()

        '	Set the AlwaysInEditMode property to false
        Me.UltraDateTimeEditor1.AlwaysInEditMode = False

        '	Don't allow null values
        Me.UltraDateTimeEditor1.Nullable = False

        '	Set the DateTime property to the current date
        Me.UltraDateTimeEditor1.DateTime = DateTime.Today

        '	Use the text selection-related properties to clear the edit portion
        Me.UltraDateTimeEditor1.SelectionStart = 0
        Me.UltraDateTimeEditor1.SelectionLength = Me.UltraDateTimeEditor1.Value.ToString().Length
        Me.UltraDateTimeEditor1.SelectedText = ""

    End Sub

    Private Sub UltraDateTimeEditor1_BeforeDropDown(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles UltraDateTimeEditor1.BeforeDropDown

        If (Not Me.UltraDateTimeEditor1.IsDateValid) Then
            e.Cancel = True
            MessageBox.Show("Please type a valid date.", "BeforeDropDown", MessageBoxButtons.OK)
        End If

    End Sub
using System.Diagnostics;
using Infragistics.Win;
using Infragistics.Win.UltraWinEditors;

		private void button1_Click(object sender, System.EventArgs e)
		{
			//	Set focus to the UltraDateTimeEditor
			this.ultraDateTimeEditor1.Focus();

			//	Set the AlwaysInEditMode property to false
			this.ultraDateTimeEditor1.AlwaysInEditMode = false;

			//	Don't allow null values
			this.ultraDateTimeEditor1.Nullable = false;
		
			//	Set the DateTime property to the current date
			this.ultraDateTimeEditor1.DateTime = DateTime.Today;

			//	Use the text selection-related properties to clear the edit portion
			this.ultraDateTimeEditor1.SelectionStart = 0;
			this.ultraDateTimeEditor1.SelectionLength = this.ultraDateTimeEditor1.Value.ToString().Length;
			this.ultraDateTimeEditor1.SelectedText = "";
		}	

		private void ultraDateTimeEditor1_BeforeDropDown(object sender, System.ComponentModel.CancelEventArgs e)
		{
			if ( ! this.ultraDateTimeEditor1.IsDateValid )
			{
				e.Cancel = true;

				MessageBox.Show( "Please type a valid date.", "BeforeDropDown", MessageBoxButtons.OK );
			}
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also