找回密码
 立即注册

QQ登录

只需一步,快速开始

qinbinghao

初级会员

32

主题

93

帖子

295

积分

初级会员

积分
295

活字格认证微信认证勋章

qinbinghao
初级会员   /  发表于:2013-11-8 15:34  /   查看:5068  /  回复:3
Spread for WinForm 7.0  PC win7
Dim B As Object = RangeCell.CellType
  RangeCell.CellType = B
B.NumberFormat = New System.Globalization.NumberFormatInfo
NumberFormat.CurrencySymbol="US$"   
默认显示在数字的左边

如何把GeneralCellType .NumberFormat.CurrencySymbol显示在数字的右边

3 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-11-8 18:37:00
沙发
回复 1楼qinbinghao的帖子

qinbinghao 你好,
当前 Spread 无法实现这个功能,需要通过自定义单元格类型实现:

  1. public partial class Form1 : Form
  2.     {
  3.         public Form1()
  4.         {
  5.             InitializeComponent();
  6.              MyCurrecyCellType myType = new MyCurrecyCellType();
  7.              myType.DecimalPlaces = 0;
  8.              this.fpSpread1.Sheets[0].Columns[0].CellType = myType;
  9.         }
  10.     }

  11.     class MyCurrecyCellType:NumberCellType
  12.     {
  13.         public override string Format(object obj)
  14.         {
  15.             string formatstr="";
  16.             if (obj != null)
  17.             {
  18.                 formatstr = obj.ToString() + "$";
  19.             }
  20.             return formatstr;
  21.         }
  22.     }
复制代码
回复 使用道具 举报
qinbinghao
初级会员   /  发表于:2013-11-9 11:18:00
板凳
请给VB.NET 代码
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-11-11 10:34:00
地板
回复 3楼qinbinghao的帖子

VB.NET 代码如下:

  1. Imports FarPoint.Win.Spread.CellType

  2. Public Class Form1

  3.     Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  4.         Dim myType As New MyCurrecyCellType()
  5.         myType.DecimalPlaces = 0
  6.         Me.FpSpread1.Sheets(0).Columns(0).CellType = myType

  7.     End Sub
  8. End Class

  9. Class MyCurrecyCellType
  10.     Inherits NumberCellType
  11.     Public Overrides Function Format(obj As Object) As String
  12.         Dim formatstr As String = ""
  13.         If obj IsNot Nothing Then
  14.             formatstr = obj.ToString() & "$"
  15.         End If
  16.         Return formatstr
  17.     End Function
  18. End Class
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部