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

推荐订阅源

V
V2EX
P
Proofpoint News Feed
D
DataBreaches.Net
C
Check Point Blog
L
LangChain Blog
量子位
美团技术团队
Vercel News
Vercel News
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
V
Visual Studio Blog
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
U
Unit 42
腾讯CDC
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale

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

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";
                    }
                }
            }