「UI美化」Winform数据网格如何绑定数据

点击获取工具>>express

先决条件

平台:服务器

  • Frameworks (XAF & XPO)
  • WinForms

产品:session

这些新的只读服务器模式组件是XPServerCollectionSource/XPInstantFeedbackSourceXPView 的混合,可与DevExpress Grid控件一块儿使用。工具

它们提供如下内容:设计

  • 能以较低的内存使用量处理大型数据源(不会加载整个持久对象实例)。
  • 能自定义SELECT语句并排除未使用的数据列。
  • 能在根查询中包括引用属性数据,以免1 + N问题。
  • 能包含使用ServerViewProperty在服务器端计算的自定义(虚拟)属性。

在将这些组件用做网格的数据源以前,请按如下方式配置它们:orm

  1. 在代码或组件设计器中设置ObjectType和Properties,ServerViewProperty支持表达式中的持久性或别名属性。

C#对象

`xpServerModeView1.ObjectType = typeof(Order);
xpInstantFeedbackView1.ObjectType = typeof(Order);事件

var viewProperties = new ServerViewProperty[] {
new ServerViewProperty("Oid", SortDirection.Ascending, "[Oid]"),
new ServerViewProperty("OrderDate", SortDirection.None, "[OrderDate]"),
new ServerViewProperty("Customer", SortDirection.None, "[Customer.ContactName]"),
new ServerViewProperty("ProductName", SortDirection.None, "[ProductName]"),
new ServerViewProperty("Price", SortDirection.None, "[Price]"),
new ServerViewProperty("Quantity", SortDirection.None, "[Quantity]"),
new ServerViewProperty("TotalPrice", SortDirection.None, "[Quantity] * [Price]"),
new ServerViewProperty("Tax", SortDirection.None, "[Quantity] [Price] 0.13")
};
xpServerModeView1.Properties.AddRange(viewProperties);
xpInstantFeedbackView1.Properties.AddRange(viewProperties);`内存

  1. 处理ResolveSession事件来提供一个Session,以从数据存储中检索对象。

C#get

`session = new Session(XpoDefault.DataLayer);

xpServerModeView1.ResolveSession += (s, e) => {
e.Session = session;
};

xpInstantFeedbackView1.ResolveSession += (s, e) => {
e.Session = session;
};`

  1. 对于XPInstantFeedbackView,能够选择处理DismissSession事件以手动处理在ResolveSession事件处理程序中建立的Session。

C#

`xpInstantFeedbackView1.DismissSession += (s, e) => {IDisposable session = e.Session as IDisposable;if (session != null) {session.Dispose();}};`

相关文章
相关标签/搜索