Version

AllowNull Property

Determines whether the date can be cleared.
Syntax
'Declaration
 
Public Property AllowNull As Boolean
public bool AllowNull {get; set;}
Remarks

By default, the UltraCalendarCombo will allow the Value to be cleared. This can be done by the user by selecting the text in the edit portion of the control and hitting delete or by clicking on a NullDate type Infragistics.Win.UltraWinSchedule.CalendarCombo.DateButton in the dropdown. When this occurs, the Value is set to DBNull to indicate that no date is set. When the control does not have focus and the Value is set to DBNull.Value, the edit portion will display the NullDateLabel.

Note, the AllowNull property cannot be set to false if the Value is currently set to DBNull.Value.

Example
This example configures the control to allow or disallow the Value property to be set to null. If the value of the 'allow' parameter is false, and the current value is null, it sets the Value property to the current date so that no exception is thrown.

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Imports Infragistics.Win.UltraWinSchedule.CalendarCombo

    Private Sub AllowNullValues(ByVal allow As Boolean)

        If (allow) Then
            '	Set AllowNull to true
            Me.ultraCalendarCombo1.AllowNull = True

            '	Set the NullDateLabel to "(no date selected)", which the control
            '	will display when the Value property is set to null
            Me.ultraCalendarCombo1.NullDateLabel = "(no date selected)"
        Else
            '	If the Value property is null, we can't set AllowNull to false,
            '	or an exception will be thrown. When that is the case, change
            '	the Value to the current date.
            If Me.ultraCalendarCombo1.Value Is Nothing Or Me.ultraCalendarCombo1.Value Is DBNull.Value Then
                Me.ultraCalendarCombo1.Value = DateTime.Today

                '	Now set the AllowNull property
                Me.ultraCalendarCombo1.AllowNull = False
            End If
        End If

    End Sub
using Infragistics.Win;
using Infragistics.Win.UltraWinSchedule;
using Infragistics.Win.UltraWinSchedule.CalendarCombo;

		private void AllowNullValues( bool allow )
		{

			if ( allow )
			{
				//	Set AllowNull to true
				this.ultraCalendarCombo1.AllowNull = true;

				//	Set the NullDateLabel to "(no date selected)", which the control
				//	will display when the Value property is set to null
				this.ultraCalendarCombo1.NullDateLabel = "(no date selected)";
			}
			else
			{
				//	If the Value property is null, we can't set AllowNull to false,
				//	or an exception will be thrown. When that is the case, change
				//	the Value to the current date.
				if ( this.ultraCalendarCombo1.Value == null ||
               this.ultraCalendarCombo1.Value == DBNull.Value )
					this.ultraCalendarCombo1.Value = DateTime.Today;

				//	Now set the AllowNull property
				this.ultraCalendarCombo1.AllowNull = false;
			}

		}
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