Input for WinForms
型の書式設定
データの書式設定 > 型の書式設定

By default (FormatType property is set to DefaultFormat), the Text is obtained by applying the standard ToString() method of the current DataType to the typed Value (more exactly, if the type has a type converter, TypeConverter.ToString() is used). This conversion (as all others) uses the regional settings provided by the CultureInfo property.

Formatting is controlled by the FormatType property. Its enumerated values define the method of formatting values. Some of the options correspond to standard format specifiers for numeric and date-time types, for example, the StandardNumber and LongDate formats, for more information see Formatting Types in the .NET Framework documentation. One option, CustomFormat, corresponds to the case of a custom format specifier as defined in the .NET Framework documentation, the specifier itself is determined by the CustomFormat property. There is also an option delegating formatting to code in an event. The following table describes the list of available options:

書式設定オプション 説明
DefaultFormat TypeConverter.ConvertToString() を使用して変換を行います。
UseEvent Formatting イベント(または Parsing イベント)内のユーザーコードによって変換が行われます。
CustomFormat 書式設定には、CustomFormat プロパティに割り当てられた文字列が使用されます。解析には、NumberStyle、DateTimeStyle、CustomFormat の各プロパティが使用されます。
GeneralNumber 固定小数点または指数表記を使用して、数値が最も簡単な小数形式に変換されます。
Currency 数値は、金額を表す文字列に変換されます。
FixedPoint 数値は、「-ddd.ddd…」形式の文字列に変換されます。「d」はそれぞれ数字(0〜9)を示します。数値が負である場合は、文字列の先頭にマイナス記号(-)が付加されます。数値の精度は、指定されたカルチャの NumberFormatInfo.NumberDecimalDigits プロパティによって決定されます。
StandardNumber 数値は、「-d,ddd,ddd.ddd…」形式の文字列に変換されます。「d」はそれぞれ数字(0〜9)を示します。数値が負である場合は、文字列の先頭にマイナス記号(-)が付加されます。小数点の左側には、3桁ごとに桁区切りが挿入されます。数値の精度は、指定されたカルチャの NumberFormatInfo.NumberDecimalDigits プロパティによって決定されます。
Percent 数値は、NumberFormatInfo.PercentNegativePattern プロパティまたは NumberFormatInfo.PercentPositivePattern プロパティの定義に従って、パーセンテージを表す文字列に変換されます。数値が負の場合、生成される文字列は PercentNegativePattern によって定義され、先頭にマイナス記号(-)が付加されます。変換された数値は 100 倍されて、パーセンテージで示されます。NumberFormatInfo によって指定されるデフォルトの数値精度が使用されます。
Scientific 数値は、「-d.ddd…E+ddd」または「-d.ddd…e+ddd」形式の文字列に変換されます。「d」はそれぞれ数字(0〜9)を示します。数値が負である場合は、文字列の先頭にマイナス記号(-)が付加されます。小数点の前には、常に1桁の数字が置かれます。指数は、常にプラス記号(+)またはマイナス記号(-)と3桁以上の数字で表されます。この形式でない場合は、必要に応じて指数に0が付加されます。
RoundTrip ラウンドトリップ指定子を指定すると、文字列に変換された数値が再度同じ数値に解析されます。この書式は、浮動小数点型でのみサポートされています。
Integer 数値が十進法の数値を含む文字列として表示されます。この書式は、整数型でのみサポートされています。
Hexadecimal 数値が 16 進数字の文字列に変換されます。この書式は、整数型でのみサポートされています。
YesNo ブール値に変換され、False の場合は No、True の場合は Yes と表示されます。
TrueFalse ブール値に変換され、True または False と表示されます。
OnOff ブール値に変換され、False の場合は Off、True の場合は On と表示されます。
GeneralDate 標準の日付/時刻パターン(短い書式)です。
LongDate 指定された CultureInfo の長い日付書式に従って、日付が表示されます。
MediumDate 中間の長さの日付書式(dd-MMM-yy)で日付が表示されます。
ShortDate 指定された CultureInfo の短い日付書式で日付が表示されます。
LongTime ロケールの長い時刻書式(時間、分、秒を含む)で時刻が表示されます。
MediumTime 時間と分から成る 12 時間形式と AM/PM 指定子で、時刻が表示されます(hh:mm tt)。
ShortTime 24 時間形式で時刻が表示されます(「17:45」など)。
LongDateShortTime 指定された CultureInfo の書式に従って、日付が長い書式で、また時刻が短い書式で表示されます。
LongDateLongTime 指定された CultureInfo の書式に従って、日付が長い書式で、また時刻が長い書式で表示されます。
ShortDateShortTime 指定された CultureInfo の書式に従って、日付が短い書式で、また時刻が短い書式で表示されます。
ShortDateLongTime 指定された CultureInfo の書式に従って、日付が短い書式で、また時刻が長い書式で表示されます。
MonthAndDay 日付の月と日が表示されます。
DateAndTimeGMT 日付/時刻がグリニッジ標準時(GMT)として書式設定されます。
DateTimeSortable 日付/時刻がソート可能なインデックスとして書式設定されます。
GMTSortable 日付/時刻が GMT でソート可能なインデックスとして書式設定されます。
LongDateTimeGMT 日付/時刻が長い書式で GMT として書式設定されます。
YearAndMonth 日付が年と月として書式設定されます。