When editing date-time data with the property DateTimeInput set to True, the C1TextBox and C1DateEdit controls work in a special mode. In this mode, instead of editing date-time values as regular strings, they are divided into separate fields for month, day, hour, and so on. It looks similar to the standard DateTimePicker control. However, C1TextBox and C1DateEdit support more formats than the standard DateTimePicker control and have many additional features, such as time zone adjustment, culture-dependent date formatting, and so on.
Control | Property | Value |
---|---|---|
C1Label1 | TextDetached | True |
Text | OrderID: | |
C1Label3 | TextDetached | True |
Text | Order Date: | |
C1Label4 | TextDetached | True |
Text | Required Date: | |
C1Label5 | TextDetached | True |
Text | Shipped Date/Time (in local time zone): | |
C1Labe6 | TextDetached | True |
Text | Shipped Date/Time (stored in Mountain Standard Time - GMT-07:00): | |
C1Label8 | TextDetached | True |
Text | Enter date using Thai Buddist calendar: | |
C1Label9 | TextDetached | True |
Text | Time in custom format (HH:mm:ss:fff): | |
Button1 | Name | btnClose |
Text | Close |
Also, you need to set the AutoIncrement property of the OrderID field of C1ExpressTable1, otherwise you will not be able to update data in the database.
Control | Property | Value |
---|---|---|
C1DbNavigator1 | DataSource | C1ExpressTable1 |
C1Label2 | DataSource | C1ExpressTable1 |
DataField | OrderID | |
C1TextBox1 | DataSource | C1ExpressTable1 |
DataField | OrderDate | |
C1TextBox2 | DataSource | C1ExpressTable1 |
DataField | RequiredDate | |
C1TextBox3 | DataSource | C1ExpressTable1 |
DataField | ShippedDate | |
C1Label7 | DataSource | C1ExpressTable1 |
DataField | ShippedDate |
Set up the navigator control C1DbNavigator1:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub C1DbNavigator1_RefreshData(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1DbNavigator1.RefreshData C1ExpressTable1.ExpressConnection.Fill() End Sub Private Sub C1DbNavigator1_UpdateData(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1DbNavigator1.UpdateData C1ExpressTable1.ExpressConnection.Update() End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void C1DbNavigator1_RefreshData(object sender, System.EventArgs e) { C1ExpressTable1.ExpressConnection.Fill(); } private void C1DbNavigator1_UpdateData(object sender, System.EventArgs e) { C1ExpressTable1.ExpressConnection.Update(); } |
Since we leave the DateTimeInput property with its default value True, we will get date-time editing with separate fields for day of week, month, day, and year at run time. In the C1TextBox2 control, set the FormatType to ShortDate.
LongDate and ShortDate are examples of standard .NET formats. Their actual representation depends on the regional settings controlled by the Culture property.
Control | Property | Value |
---|---|---|
C1TextBox3 | FormatType | CustomFormat |
CustomFormat | MM/dd/yyyy h:mm tt zzz |
This format is the control’s default format (where tt is the AM/PM designator and zzz is the time zone representation). We can override it, and other format-related properties, for display and/or edit mode using properties DisplayFormat and EditFormat. Expand the DisplayFormat property, then expand its sub-property (Inherit) and select False for the FormatType flag. That will break the inheritance from control for the FormatType property and allow us to change it. Set this property, and also set the FormatType property for C1Label7 at this time to the following:
Control | Property | Value |
---|---|---|
C1TextBox3 | DisplayFormat.FormatType | LongDateShortTime |
C1Label7 | FormatType | LongDateShortTime |
Control | Property | Value |
---|---|---|
C1TextBox3 | NullText | (not shipped yet) |
EmptyAsNull | True | |
C1Label7 | NullText | (null) |
By default, clearing the control (select all and pressing Delete) reverts it to the value it had before editing once the control loses focus. We changed this behavior setting the EmptyAsNull property to True, now clearing the control sets its value to DBNull.
For the C1TextBox3 control:
Since this control is not data bound, to start editing from a non-empty value, set the Value property to some date-time value.