AdjustFormatPrecision(Delta: Integer);
Delta is the number of characters by which it is necessary to change the precision of the established format. If the Delta parameter has a positive value, the format precision is increased. If it is negative, the precision is decreased by the specified number of characters.
The AdjustFormatPrecision method changes precision of custom format.
Custom format of data displaying is specified in the CustomFormat or the LocalCustomFormat properties. This method is used to change precision of numerical, currency, percentage and exponential formats.
Executing the example requires a form. On the form there are three buttons named Button1, Button2 and Button3. Also, the form contains a TabSheetBox component and a UiTabSheet component which is used as a data source for the TabSheetBox component.
Class UserForm: Form
UiTabSheet1: UiTabSheet;
TabSheetBox1: TabSheetBox;
Button1: Button;
Button2: Button;
Button3: Button;
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
TSheet: ITabSheet;
TRange: ITabRange;
Style: ITabCellStyle;
Begin
TSheet := UiTabSheet1.TabSheet;
TRange := TSheet.View.Selection.Range;
Style := TRange.Style;
Style.CustomFormat := "# ##0,00";
End Sub Button1OnClick;
Sub Button2OnClick(Sender: Object; Args: IMouseEventArgs);
Var
TSheet: ITabSheet;
TRange: ITabRange;
Style: ITabCellStyle;
Begin
TSheet := UiTabSheet1.TabSheet;
TRange := TSheet.View.Selection.Range;
Style := TRange.Style;
Style.AdjustFormatPrecision(2);
End Sub Button2OnClick;
Sub Button3OnClick(Sender: Object; Args: IMouseEventArgs);
Var
TSheet: ITabSheet;
TRange: ITabRange;
Style: ITabCellStyle;
Begin
TSheet := UiTabSheet1.TabSheet;
TRange := TSheet.View.Selection.Range;
Style := TRange.Style;
Style.AdjustFormatPrecision(-2);
End Sub Button3OnClick;
End Class UserForm;
After the form is started, it is necessary to select a table cell range. On clicking the Button1 a custom numeric format for the selected range is set. Precision of the established format is two decimals after the point. Each click on the Button2 increases the precision of values in the selected range by two decimals after the point. On clicking the Button3 the precision of values in the selected range is decreased by two decimals after the point.
See also: