翻譯|使用教程|編輯:龔雪|2020-12-14 10:35:08.300|閱讀 481 次
概述:本文將詳細為大家介紹如何使用XPO和XPServerModeView或XPInstantFeedbackView將數據綁定到WinForms Data Grid中,DevExpress WinFormsv20.2.4日前已正式發布,歡迎下載最新版體驗!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
下載DevExpress v20.2完整版 DevExpress v20.2漢化資源獲取
DevExpress WinForms能完美構建流暢、美觀且易于使用的應用程序,無論是Office風格的界面,還是分析處理大批量的業務數據,它都能輕松勝任!更多Winfrom幫助文檔請點擊到下載頁面獲取>>
平臺:
產品:
這些新的只讀服務器模式組件是/和 的混合,可與DevExpress Grid控件一起使用。
它們提供以下內容:
在將這些組件用作網格的數據源之前,請按以下方式配置它們:
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);
2. 處理ResolveSession事件來提供一個Session,以從數據存儲中檢索對象。
C#
session = new Session(XpoDefault.DataLayer); xpServerModeView1.ResolveSession += (s, e) => { e.Session = session; }; xpInstantFeedbackView1.ResolveSession += (s, e) => { e.Session = session; };
3. 對于XPInstantFeedbackView,可以選擇處理DismissSession事件以手動處理在ResolveSession事件處理程序中創建的Session。
C#
xpInstantFeedbackView1.DismissSession += (s, e) => { IDisposable session = e.Session as IDisposable; if (session != null) { session.Dispose(); } };
DevExpress技術交流群2:775869749 歡迎一起進群討論
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都網