找回密码
 立即注册

QQ登录

只需一步,快速开始

ccwinder

中级会员

1

主题

8

帖子

671

积分

中级会员

积分
671

活字格认证

最新发帖
ccwinder
中级会员   /  发表于:2011-7-26 09:26  /   查看:7398  /  回复:7
1、像会计软件一样,负数显示为红字,零不显示,正数正常显示,不知道怎样设置?
2、显示格式需要逗号分隔。

7 个回复

倒序浏览
barrylei
中级会员   /  发表于:2011-7-26 10:08:00
沙发
确认一下,你用的MultiRow版本是多少?
在你的应用程序里,是否使用了Inputman的空间?
回复 使用道具 举报
ccwinder
中级会员   /  发表于:2011-7-26 10:54:00
板凳
版本是5.0C,没有使用Inputman
回复 使用道具 举报
ccwinder
中级会员   /  发表于:2011-7-26 11:19:00
地板
对不起,使用得是6.0C
回复 使用道具 举报
robert
金牌服务用户   /  发表于:2011-7-26 13:37:00
5#
C#
  1.         private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             this.gcMultiRow.CellFormatting += new EventHandler<CellFormattingEventArgs>(gcMultiRow_CellFormatting);
  4.         }
  5.         void gcMultiRow_CellFormatting(object sender, CellFormattingEventArgs e)
  6.         {
  7.             if (e.Value != null)
  8.             {
  9.                 int value;
  10.                 if (int.TryParse(e.Value.ToString(), out value))
  11.                 {
  12.                     if (value < 0)
  13.                     {
  14.                         e.CellStyle.ForeColor = Color.Red;
  15.                         e.CellStyle.SelectionForeColor = Color.Red;
  16.                     }
  17.                 }
  18.             }
  19.         }
复制代码
回复 使用道具 举报
robert
金牌服务用户   /  发表于:2011-7-26 13:39:00
6#
VB
  1.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
  2.         AddHandler Me.gcMultiRow.CellFormatting, AddressOf gcMultiRow_CellFormatting
  3.     End Sub
  4.     Private Sub gcMultiRow_CellFormatting(ByVal sender As Object, ByVal e As CellFormattingEventArgs)
  5.         If e.Value IsNot Nothing Then
  6.             Dim value As Integer
  7.             If Integer.TryParse(e.Value.ToString(), value) Then
  8.                 If value &lt; 0 Then
  9.                     e.CellStyle.ForeColor = Color.Red
  10.                     e.CellStyle.SelectionForeColor = Color.Red
  11.                 End If
  12.             End If
  13.         End If
  14.     End Sub
复制代码
回复 使用道具 举报
ccwinder
中级会员   /  发表于:2011-7-26 15:19:00
7#
这样负数是显示为红字了,可是按中国人习惯,红字就表示负数。
效果应该没有“-”号
回复 使用道具 举报
robert
金牌服务用户   /  发表于:2011-7-26 15:43:00
8#
void gcMultiRow_CellFormatting(object sender, CellFormattingEventArgs e)
        {
            if (e.Value != null)
            {
                int value;
                if (int.TryParse(e.Value.ToString(), out value))
                {
                    if (value &lt; 0)
                    {
                        e.CellStyle.ForeColor = Color.Red;
                        e.CellStyle.SelectionForeColor = Color.Red;
                        e.Value = -value;
                    }
                }
            }
        }

在e.CellStyle.SelectionForeColor = Color.Red; 这句后边加一句e.Value = -value; 看是否可以满足你的需求
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部