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