Data value formatting and functions
[Visual Basic]
Public Sub SetGridFormatCellFunction( _
ByVal
Column As
Integer, _
ByVal
Value As
String _
)
[C#]
public
void SetGridFormatCellFunction(
int Column,
string Value);
Parameters
-
Column
- Column number starting at 1
-
Value
- Usage
SetGridFormatCellFunction(ColumnNumber, "FunctionName [, args, ...]")
Remarks
Data value formatting and functions
Most of these functions represents their Visual Basic equivalents.
Formatting functions :
FormatCurrency [,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]]
FormatNumber[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]]
FormatPercent [,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]]
NumDigitsAfterDecimal Optional.
Numeric value indicating how many places to the right of the decimal are displayed. Default value is –1, which indicates that the computer's regional settings are used.
IncludeLeadingDigit Optional.
Tristate constant that indicates whether or not a leading zero is displayed for fractional values.
UseParensForNegativeNumbers Optional.
Tristate constant that indicates whether or not to place negative values within parentheses.
GroupDigits Optional.
Tristate constant that indicates whether or not numbers are grouped using the group delimiter specified in the computer's regional settings.
Settings
The IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits arguments have the following settings:
1 : True
0 : False
2 : Use the setting from the computer's regional settings.
FormatDateTime [,NamedFormat] The NamedFormat argument has the following settings:
0 : Display a date and/or time. If there is a date part, display it as a short date. If there is a time part, display it as a long time. If present, both parts are displayed.
1 : Display a date using the long date format specified in your computer's regional settings.
2 : Display a date using the short date format specified in your computer's regional settings.
3 : Display a time using the time format specified in your computer's regional settings.
4 : Display a time using the 24-hour format (hh:mm).
Format [, format[, firstdayofweek[, firstweekofyear]]] The Format function syntax has these parts:
format : Optional. A valid named or user-defined format expression.
firstdayofweek : Optional. Aconstant that specifies the first day of the week.
firstweekofyear : Optional. A constant that specifies the first week of the year.
Settings
The firstdayofweekargument has these settings:
0 : Use NLS API setting.
1 : Sunday (default)
2 : Monday
3 : Tuesday
4 : Wednesday
5 : Thursday
6 : Friday
7 : Saturday
The firstweekofyear argument has these settings:
0 : Use NLS API setting.
1 : Start with week in which January 1 occurs (default).
2 : Start with the first week that has at least four days in the year.
3 : Start with the first full week of the year.
Remarks
To Format Numbers : Use predefined named numeric formats or create user-defined numeric formats.
To Format Dates and times : Use predefined named date/time formats or create user-defined date/time formats.
To Format Date and time serial numbers : Use date and time formats or numeric formats.
To Format Strings : Create your own user-defined string formats.
If you try to format a number without specifying format, Format provides functionality similar to the Str function, although it is internationally aware. However, positive numbers formatted as strings using Format don’t include a leading space reserved for the sign of the value; those converted using Str retain the leading space.
Other : DateAdd, interval, number * interval Required. String expression that is the interval of time you want to add.
* number Required. Numeric expression that is the number of intervals you want to add. It can be positive (to get dates in the future) or negative (to get dates in the past).
Settings
The intervalargument has these settings:
Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second
DatePart, interval * interval Required. String expression that is the interval of time you want to return.
Settings
See above!
Replace, find, replacewith [,start[,count]] Left, length Right, length Mid, start[,length] UCase LCase InitCaps InitCapsAll Len Round [,numdecimalplaces] Abs E.g.
SetGridFormatCellFunction(1, "Mid,10,20")
SetGridFormatCellFunction(2, "Replace, USA, Unites States of America")
SetGridFormatCellFunction(3, "FormatNumber, 2, -1, -2, -1")
SetGridFormatCellFunction(4, "FormatCurrency, 2")
SetGridFormatCellFunction(5, "Round")
SetGridFormatCellFunction(6, "Abs")
SetGridFormatCellFunction(7, "FormatPercent, 0")
SetGridFormatCellFunction(8, "Exp")
SetGridFormatCellFunction(9, "Format,dddd mmm dd yyyy")
SetGridFormatCellFunction(10, "FormatDateTime,1")
SetGridFormatCellFunction(11, "DatePart,q")
SetGridFormatCellFunction(12, "InitCapsAll")
Note. GridFormatCellFunction can only be applied once per column.
Regular Expressions The regular expression syntax follows the .NET Regular Expression syntax
Example - Highlight words with yellow background:
SetGridFormatCellFunction(1, "RegExpReplace, /(\sMicrosoft|\sIBM)/g,<span style=""background-color:yellow"">$1</span>")
See Also
AxpDataGrid Class | Axezz.WebControls Namespace