DataFormat Property

See Also    Examples    Applies To

Returns/sets the StdDataFormat object which is used to format the obj. Read/write both at design time and run time.

Property DataFormat As StdDataFormat

obj.DataFormat
Set obj.DataFormat = formatobject

See also the VB documentation.

txt control

Various formats may be set. You may use a date format (like "General Date", "Short Date", "yyyy-mm-dd", "hh:mm", "ddd, mmm dd. yyyy hh:mm") to enable the datepicker. If the txt control is bound to a column of an atb control the DataFormat property is inherited from the column's DataFormat property. Note that unlike the TextBox control the DataFormat works even when the txt control is not bound. It defines the relation between txt.Value (unformatted) and txt.Text (formatted).

chk control

Use DataFormat.Type = fmtBoolean. Use DataFormat.TrueValue to specify the value which represents a checked box in your database field. Use DataFormat.FalseValue to specify the value which represents an unchecked box in your database field. Use DataFormat.NullValue to specify the value which represents a grayed box in your database field. Specify the same value both in DataFormat.FalseValue and DataFormat.NullValue to enable a 2-state checkbox (without the grayed case). The DataFormat overrrides the TrueValue and FalseValue properties of the chk control.

column object

Currently there is no programmatically access to the column.DataFormat property, but you may set the DataFormat at design time using atb's property page.

Automatic formats of column object

In most cases you do not need to specify a DataFormat - atb uses the right one automatically:

Numeric columns
You may input any number. If there is a numeric scale defined with the field, it is used to format the display.
Currency columns
The field is displayed using your system's currency format. The Visual Basic function CCur is used to transform your input back to the database's format (i.e. you may enter the amount with or without the currency unit).
String columns
You may input any string.
Boolean columns
Uses a checkbox. 3-state is used, if the field allows nulls, 2-state if not.
Date, Time, Date/Time columns
Enables the datepicker.

If your database does not support the right type you may override this limitation using a DataFormat. E.g. to specify a 3-state checkbox in oracle use a char(1) field with nulls allowed and set the format as shown below:

If there is a txt or chk control bound to your column, the control inherits the DataFormat of the column if it has not defined it's own DataFormat.

Options format of column and txt objects

You may use the Options format to choose one of several values for the column or txt control. Note that for every option there is a text (caption used to describe the value) and the value itself. In atb's form view (i.e. for column objects) a dropdown box is used. For txt controls the height of the control determines which one of three styles is used: combo box, list box or options field.

Lets take a look at the example you can find in the Customers form of the Northwind example application.

The txt control txtDemo has a custom DataFormat:

Options("This gives &a 1",1,"This will be a &b","b","The End","End")

You will find txtDemo with a Height of 1170 which yields an options field:

If you change to txtDemo.Height = 930, you will get a list box (try to make it a little smaller to get a scrollable list box):

If the Height is as small as 570, you will see a combo box (shown with drop down list here):

You can use the Options format with bound and with unbound txt controls. If you are using a bound control, you probably would prefer to define the Options format in the atb.column bound to, because the bound txt control inherits the DataFormat from the atb.column and this way you will get a consistent use of the field in grid view as well as in form view.