我的DBGrid控件是否通过数据源即DataSource和ADODataset邦定在一起的,如今我做的是“退货”功能,我希望用户输入正数,而实际数据库中保存为负数。可否通过设置DBGrid的显示格式等方式来实现呢?请高手指点。
解决方案 »
- 执行下列SQL语句时报错
- Access violation at address 016A92D0 in module 'dbexpMysql.dll',read address of 000008
- 请问如何把html转化成txt格式
- 怎样获取本机上网的DNS地址?
- ToolBar和MDI窗体的问题
- quickreport根据报表的内容自动加序号的问题
- 我失业了,有哪位好心人帮帮我!本人万分感谢!!!!!!
- 关于字符串替换的问题,真正懂的人进来,没有充分试验的免谈
- 用Delphi读取VB生成的二进制文件时,发现问题。急!急!急!
- 这几天写了一个全局hook mouse、键盘的程序,结果发现hook用在这个程序中太多
- 怎样获取html表格中的数据!!!顶者有分
- 问一个关于quickreport的问题,问题解决100分送上,分不够再加
--肯定不行的吧.
在BeforePost事件中控制吧
begin
TNumericField(DataSet.FieldByName('你的字段名')).DisplayFormat := '#;#;#';
end;procedure TForm1.Table1BeforePost(DataSet: TDataSet);
begin
DataSet.FieldByName('你的字段名').AsFloat :=
-Abs(DataSet.FieldByName('你的字段名').AsFloat);
end;
0 Digit place holder. If the value being formatted has a digit in the position where the '0' appears in the format string, then that digit is copied to the output string. Otherwise, a '0' is stored in that position in the output string.
# Digit placeholder. If the value being formatted has a digit in the position where the '#' appears in the format string, then that digit is copied to the output string. Otherwise, nothing is stored in that position in the output string.
. Decimal point. The first '.' character in the format string determines the location of the decimal separator in the formatted value; any additional '.' characters are ignored. The actual character used as a the decimal separator in the output string is determined by the DecimalSeparator global variable. The default value of DecimalSeparator is specified in the Number Format of the International section in the Windows Control Panel.
, Thousand separator. If the format string contains one or more ',' characters, the output will have thousand separators inserted between each group of three digits to the left of the decimal point. The placement and number of ',' characters in the format string does not affect the output, except to indicate that thousand separators are wanted. The actual character used as a the thousand separator in the output is determined by the ThousandSeparator global variable. The default value of ThousandSeparator is specified in the Number Format of the International section in the Windows Control Panel.
E+ Scientific notation. If any of the strings 'E+', 'E-', 'e+', or 'e-' are contained in the format string, the number is formatted using scientific notation. A group of up to four '0' characters can immediately follow the 'E+', 'E-', 'e+', or 'e-' to determine the minimum number of digits in the exponent. The 'E+' and 'e+' formats cause a plus sign to be output for positive exponents and a minus sign to be output for negative exponents. The 'E-' and 'e-' formats output a sign character only for negative exponents.
'xx'/"xx" Characters enclosed in single or double quotes are output as-is, and do not affect formatting.
; Separates sections for positive, negative, and zero numbers in the format string.
帮助文档也看了,可是英文差,能否帮忙解释一下。请问有QQ吗
ShowMessage(FormatFloat('"正"0;"负"0;"零"0', +1));
ShowMessage(FormatFloat('"正"0;"负"0;"零"0', -1));
ShowMessage(FormatFloat('"正"0;"负"0;"零"0', 0)); ShowMessage(FormatFloat('"正"00.00;"负"00.00;"零"00.00', +1));
ShowMessage(FormatFloat('"正"00.00;"负"00.00;"零"00.00', -1));
ShowMessage(FormatFloat('"正"00.00;"负"00.00;"零"00.00', 0)); ShowMessage(FormatFloat('"正"#.00;"负"#.00;"零"#.00', +1));
ShowMessage(FormatFloat('"正"#.00;"负"#.00;"零"#.00', -1));
ShowMessage(FormatFloat('"正"#.00;"负"#.00;"零"#.00', 0));
end;