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

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 聂微东
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
D
DataBreaches.Net
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
L
LangChain Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
F
Fortinet All Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks
Recent Announcements
Recent Announcements
Jina AI
Jina AI
G
Google Developers Blog
腾讯CDC
博客园_首页
博客园 - 【当耐特】

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

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(7) 读书笔记 UltraGrid(6) 读书笔记 UltraGrid(5) 读书笔记 UltraGrid(4) 读书笔记 UltraGrid(3)
读书笔记 UltraGrid(8)
木人(我现在不是老大) · 2012-02-11 · via 博客园 - 木人(我现在不是老大)

设置某一列为只读
this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].CellActivation = Activation.ActivateOnly;

选择后的缺省前景和背景色
this.ultraGrid1.DisplayLayout.DefaultSelectedBackColor = Color.Azure;
this.ultraGrid1.DisplayLayout.DefaultSelectedForeColor = Color.YellowGreen;

使用dataset绑定。
检索数据,建立table之间的关系。ultraGrid自动建立层次式展示方式。
DataSet data = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select * from customers", cnnstring);
da.Fill(data, "Customers");
da = new SqlDataAdapter("select * from pdctorders", cnnstring);
da.Fill(data, "PdctOrders");
DataRelation mydr = new DataRelation("Customers_PdctOrders", data.Tables["Customers"].Columns["CustID"], data.Tables["pdctorders"].Columns["CustID"], false);
data.Relations.Add(mydr);

da = new SqlDataAdapter("select * from SaleContracts", cnnstring);
da.Fill(data, "SaleContracts");
DataRelation mydr2 = new DataRelation("Customers_SaleContracts", data.Tables["Customers"].Columns["CustID"], data.Tables["SaleContracts"].Columns["CustID"],

false);
data.Relations.Add(mydr2);

this.ultraGrid1.DataSource = data;
1)系统自动根据源数据的类型选择合适的控件展示,如日历控件、单选框等;
2)缺省都是左对齐的;
3)所有数据原样显示,没有格式化的。

如何根据数据类型自动设置列,如格式、对齐等?
            foreach (UltraGridBand ugb in this.ultraGrid1.DisplayLayout.Bands)
            {
                foreach (UltraGridColumn ugc in ugb.Columns)
                {
                    if (ugc.DataType == Type.GetType("System.Int8") ||
                        ugc.DataType == Type.GetType("System.Int16") ||
                        ugc.DataType == Type.GetType("System.Int32") ||
                        ugc.DataType == Type.GetType("System.Int64"))
                    {
                        ugc.Format = "#,#";
                        ugc.CellAppearance.TextHAlign = HAlign.Right;
                    }
                    else if (ugc.DataType == Type.GetType("System.Single") ||
                        ugc.DataType == Type.GetType("System.Double"))
                    {
                        ugc.Format = "#,0.00";
                        ugc.CellAppearance.TextHAlign = HAlign.Right;
                    }
                    else if (ugc.DataType == Type.GetType("System.DateTime"))
                    {
                        ugc.Format = "yyyy/MM/dd";
                        ugc.MaskInput = "yyyy/mm/dd";
                    }
                }
            }