惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
小众软件
小众软件
I
InfoQ
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Martin Fowler
Martin Fowler
月光博客
月光博客
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
V
Visual Studio Blog
博客园 - 叶小钗
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - 木人(我现在不是老大)

ERP系统的专业化发展趋势 讨厌的real和float数据 Svcutil使用点滴 windows server2003企业版64位安装sql server2008企业版64位 读书笔记 UltraGrid(16) 水晶报表使用push模式(2) 水晶报表使用push模式(1) SQL SERVER2000存储过程调试 读书笔记 UltraGrid(15) 读书笔记 UltraGrid(14) 读书笔记 UltraGrid(12) 读书笔记 UltraGrid(11) 读书笔记 UltraGrid(10) 读书笔记 UltraGrid(9) 读书笔记 UltraGrid(8) 读书笔记 UltraGrid(6) 读书笔记 UltraGrid(5) 读书笔记 UltraGrid(4) 读书笔记 UltraGrid(3)
读书笔记 UltraGrid(7)
木人(我现在不是老大) · 2012-02-11 · via 博客园 - 木人(我现在不是老大)

ultragrid的缺省编辑状态
允许删除和更新,不允许增加;
缺省删除,可以选择行,然后按【delete】键;
删除的提示信息,可通过下列方式修改:
ResourceCustomizer rc = Infragistics.Win.UltraWinGrid.Resources.Customizer;
rc.SetCustomizedString("DeleteMultipleRowsPrompt", "你选择删除{0}行!\n点击【是】则删除,否则点击【否】退出。");
rc.SetCustomizedString("DeleteRowsMessageTitle", "删除多行");
rc.SetCustomizedString("DeleteSingleRowMessageTitle", "删除行");
rc.SetCustomizedString("DeleteSingleRowPrompt", "你选择删除1行!\n点击【是】则删除,否则点击【否】退出。");

如何设置grid为只读呢?
可通过以下方式:
this.ultraGrid1.DisplayLayout.Override.AllowAddNew = AllowAddNew.No;
this.ultraGrid1.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
this.ultraGrid1.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.False;
第一句不是必须,因为缺省即如此。
这样设置后,grid就是不可以编辑的。不能用【delete】键删除。单元格也不能更新。
但还是可以通过程序来更新或者编辑的。如:
ultraGrid1.Rows[0].Delete(true);
ultraGrid1.Rows[0].Cells[0].Value = 1111;
这样设置后并不影响对文字的拷贝,可以选择部分文字来进行拷贝。这个非常重要!
同样的能达到的不能编辑的方式还有:
在ultraGrid1的InitializeRow事件中写:
e.Row.Activation = Activation.ActivateOnly;
这对band中的所有行都有效!似乎这样,如果行很多,效率是否有影响呢?

如何让grid根据显示的内容自适应宽度呢?
this.ultraGrid1.DisplayLayout.Override.AllowColSizing = AllowColSizing.Free;
foreach (UltraGridBand ugb in this.ultraGrid1.DisplayLayout.Bands)
   ugb.PerformAutoResizeColumns(false, PerformAutoSizeType.AllRowsInBand);
第一句让不同的band中的列宽可以不同。
许多时候使用
ugb.PerformAutoResizeColumns(false, PerformAutoSizeType.VisibleRows);好像计算不是那么准确的!