原創(chuàng)|使用教程|編輯:我只采一朵|2014-01-17 09:34:28.000|閱讀 2355 次
概述:本文講解如何在DashboardViewer連接到數(shù)據(jù)庫之前自定義連接設(shè)置。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
上一講跟大家介紹了如何在 DevExpress Dashboard 中繪制Ribbon UI。本文將為你展示如何在DashboardViewer連接到數(shù)據(jù)庫之前使用DashboardViewer.ConfigureDataConnection事件自定義連接設(shè)置。
這里,儀表盤的XML定義包含一個(gè)連接到Microsoft Access數(shù)據(jù)庫的路徑。如果想讓數(shù)據(jù)庫文件中的數(shù)據(jù)可視,則必須提供連接參數(shù),尤其是用戶名和密碼。DashboardViewer.ConfigureDataConnection事件的目的也在于此,它的 Access97ConnectionParameters.UserName 和 FileConnectionParametersBase.Password參數(shù)分別用于設(shè)置用戶名和密碼。
請參考以下代碼:
using System.Windows.Forms; using DevExpress.DataAccess.ConnectionParameters; namespace Dashboard_ConfigureDataConnection { public partial class Form1 : Form { public Form1() { InitializeComponent(); // Loads a dashboard from an XML file. dashboardViewer1.LoadDashboard(@"..\..\Data\nwindDashboard.xml"); } // Handles the ConfigureDataConnection event. private void dashboardViewer1_ConfigureDataConnection(object sender, DevExpress.DataAccess.ConfigureDataConnectionEventArgs e) { // Checks the name of the connection for which the event has been raised. if (e.ConnectionName == "nwindConnection") { // Gets the connection parameters used to establish a connection to the database. Access97ConnectionParameters parameters = (Access97ConnectionParameters)e.ConnectionParameters; // Specifies the user name used to access the database file. parameters.UserName = "Admin"; // Specifies the password used to access the database file. parameters.Password = "password"; } } } }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件