找回密码
 立即注册

QQ登录

只需一步,快速开始

songxin

银牌会员

9

主题

48

帖子

2075

积分

银牌会员

积分
2075

活字格认证

songxin
银牌会员   /  发表于:2011-9-8 12:02  /   查看:10958  /  回复:16
C1DataView中的StringFormat="{###,###,##}"和 ConverterParameter=\{0:N0\}}的格式,希望数据为12,345,却都不好用。该如何设置?

16 个回复

正序浏览
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2011-9-14 17:43:00
17#
原帖由 songxin 于 2011-9-9 11:13:00 发表
这个是光标焦点在cell上格式是正确的1,234,光标离开就变成1234了


我的代码如下,在编辑和非编辑状态下都是显示的123,456,你有尝试过这种方法吗:                        <c1:C1DataGrid.Columns>
                <c1ataGridNumericColumn Binding="{Binding Price, Mode=TwoWay}" FilterMemberPath="rice" SortMemberPath="rice" Header="rice" Format="###,##0.00" ShowButtons="False" />
                        </c1:C1DataGrid.Columns>
回复 使用道具 举报
songxin
银牌会员   /  发表于:2011-9-14 17:24:00
16#
在DataGridTextColumn中追加属性format=“N0”就可以了
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2011-9-14 10:20:00
15#
这就很奇怪了,我先调试一下
回复 使用道具 举报
songxin
银牌会员   /  发表于:2011-9-14 09:59:00
14#

回复 13# dof 的帖子

本来想自己新建一个工程发给你 结果把我的代码重新做了一个,居然没有错误了,区别只是原来的是从viewMode进行的数据绑定(从数据库取出来的),新建工程是在xaml.cs中进行的绑定
可是在我自己的工程上就是不行,现在把绑定放在xaml.cs中了,还是不行
[code]
this.grdTechSerCostParam.LoadedCellPresenter += (s, e) =&gt;
            {
                if (e.Cell.Column.Index == 1 || e.Cell.Column.Index == 3)
                {
                    TextBlock textBlock = (e.Cell.Presenter.Content as TextBlock);
                    Binding parentBinding = textBlock.GetBindingExpression(TextBlock.TextProperty).ParentBinding;
                    Binding binding = parentBinding.Clone();
                    binding.Converter = App.Current.Resources[&quot;DecimalConverter&quot;] as DecimalConverter;
                    binding.ConverterParameter = &quot;{0:N0}&quot;;
                    binding.Mode = BindingMode.TwoWay;
                    binding.StringFormat = &quot;###,###,##&quot;;
                }   
            };
[/code]
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2011-9-9 17:39:00
13#

回复 12# songxin 的帖子

你的页面复杂吗,把页面发给我直接调试吧
回复 使用道具 举报
songxin
银牌会员   /  发表于:2011-9-9 15:37:00
12#
版主不能抛弃我啊,这个问题已经困扰我好几天了
回复 使用道具 举报
songxin
银牌会员   /  发表于:2011-9-9 11:13:00
11#

回复 10# dof 的帖子

这个是光标焦点在cell上格式是正确的1,234,光标离开就变成1234了
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2011-9-9 10:53:00
10#
如果不是自动生成列,你可以在添加列时选择添加 DataGridNumericColumn ,同时可以设置该列的Format

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
songxin
银牌会员   /  发表于:2011-9-9 10:40:00
9#
[img]C:/Users/songxin/Desktop/捕获.JPG[/img]
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部