Skip to content

GroupFormat Property

Description

Stores the string used for extra formatting of the caption text.

Property Type

Read-write property

Syntax (Visual Basic)

Public Property GroupFormat() As String

Remarks

Formatting Numbers

If the format string is set, the caption text will be formatted accordingly to this format string before drawing it. The format string uses a C-like style, similar to the sprintf() C++ function.

Only the "%s" type is supported with the Format method. This means that the Format method will only format strings and treats all numeric values as strings. If a numeric format is desired and cannot be displayed properly as a string, then do not enter a Format string; you will need to manually format your data and set this to the Caption property in the desired string format.

Example Format Strings

Here are some example format strings and how they will affect the output (if no Caption has been set):

Format String Item Value Output
"$ %s" 3.15 "$ 3.15"
"%s%%" 25 "25%"
"$ % 8s" 4.3 "$ 4.3"
"$ %.4s" 24.0536 "$ 24.0"
"%09s" .1253 "0000.1253"
"%06.4s" 3.14325 "003.14"
"My name is %s" John "My name is John"
"The %s crossed the road" chicken "The chicken crossed the road"

Formatting Dates

If the item will hold a date value, the Format property can be used to format the date.

The following are valid format flags for date values:

  • "%a" Abbreviated weekday name
  • "%A" Full weekday name
  • "%b" Abbreviated month name
  • "%B" Full month name
  • "%c" Date and time representation appropriate for locale
  • "%d" Day of month as decimal number (01 - 31)
  • "%H" Hour in 24-hour format (00 - 23)
  • "%I" Hour in 12-hour format (01 - 12)
  • "%j" Day of year as decimal number (001 - 366)
  • "%m" Month as decimal number (01 - 12)
  • "%M" Minute as decimal number (00 - 59)
  • "%p" Current locale's A.M./P.M. indicator for 12-hour clock
  • "%S" Second as decimal number (00 - 59)
  • "%U" Week of year as decimal number, with Sunday as first day of week (00 - 53)
  • "%w" Weekday as decimal number (0 - 6; Sunday is 0)
  • "%W" Week of year as decimal number, with Monday as first day of week (00 - 53)
  • "%x" Date representation for current locale
  • "%X" Time representation for current locale
  • "%y" Year without century, as decimal number (00 - 99)
  • "%Y" Year with century, as decimal number
  • "%z", "%Z" Time-zone name or abbreviation; no characters if time zone is unknown
  • "%%" Percent sign
  • "%#c" Long date and time representation, appropriate for current locale. For example: "Tuesday, March 14, 1995, 12:41:29".
  • "%#x" Long date representation, appropriate to current locale. For example: "Tuesday, March 14, 1995".
  • "%#d", "%#H", "%#I", "%#j", "%#m", "%#M", "%#S", "%#U", "%#w", "%#W", "%#y", "%#Y" Remove leading zeros (if any).

Example

Number Format Sample (Visual Basic)

This sample illustrates how to use the Format method to format numbers.

Dim Record As GridRecord  
Dim Item As GridRecordItem  

' Adds a new record/row to the GridControl  
Set Record = wndGridControl.Records.Add  
    ' Adds a GridRecordItem with a value of "RE: Your Invoice" to the new GridRecord referenced in the Record variable  
    Record.AddItem "RE: Your Invoice"  
    ' Adds a GridRecordItem with a value of "John Smith" to the new GridRecord referenced in the Record variable  
    Record.AddItem "John Smith"  
    ' Adds a GridRecordItem with a value of "19/06/2004" to the new GridRecord referenced in the Record variable  
    Record.AddItem "19/06/2004"  
    ' Adds a GridRecordItem with a value of "25" to the new GridRecord referenced in the Record variable  
    Set Item = Record.AddItem("25")  
        ' The value of "25" will now be displayed in the format "25 kb"  
        Item.Format = "%s kb"  

' Add the record/row to the GridControl  
wndGridControl.Populate  

See Also

GridGroupRow Object


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.