文檔半島外圍網上直營>>DevExpress WinForm中文手冊>>文件和文件夾瀏覽器
                文件和文件夾瀏覽器
DevExpress WinForms安裝附帶了兩個文件和文件夾瀏覽器選項:
XtraOpenFileDialog、XtraSaveFileDialog和XtraFolderBrowserDialog類實例取代了標準的Windows“Save As”、“Open”和“Browse For Folder”對話框。DevExpress對話框支持Windows Vista和更新的操作系統。
提示:要強制所有DevExpress控件和組件使用額外的對話框而不是標準的對話框,啟用WindowsFormsSettings.UseDXDialogs 屬性。
可顯示為模態對話框或嵌入到表單或用戶控件中的自定義文件夾瀏覽器,要創建這樣的瀏覽器,請使用FileExplorerAssistant組件。
 
 
如何顯示XtraSaveFileDialog
下面的示例演示如何顯示XtraSaveFileDialog。
C#:
using System.IO;
private void simpleButtonSaveFileDialog_Click(object sender, EventArgs e) {
Stream memoStream;
xtraSaveFileDialog1.Filter = "txt files (*.txt)|*.txt";
if(xtraSaveFileDialog1.ShowDialog() == DialogResult.OK) {
if((memoStream = xtraSaveFileDialog1.OpenFile()) != null) {
// Code to write the stream goes here.
memoStream.Close();
}
}
}
	點擊復制
VB.NET:
Imports System.IO Private Sub simpleButtonSaveFileDialog_Click(ByVal sender As Object, ByVal e As EventArgs) Dim memoStream As Stream xtraSaveFileDialog1.Filter = "txt files (*.txt)|*.txt" If xtraSaveFileDialog1.ShowDialog() = DialogResult.OK Then memoStream = xtraSaveFileDialog1.OpenFile() If memoStream IsNot Nothing Then ' Code to write the stream goes here. memoStream.Close() End If End If End Sub
點擊復制
如何顯示XtraOpenFileDialog
下面的示例演示如何顯示XtraOpenFileDialog。
C#:
using System.IO;
private void simpleButtonOpenFileDialog_Click(object sender, EventArgs e) {
xtraOpenFileDialog1.InitialDirectory = "c:\\";
xtraOpenFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
if(xtraOpenFileDialog1.ShowDialog() == DialogResult.OK) {
// Get the path of specified file.
string filePath = xtraOpenFileDialog1.FileName;
// Read the contents of the file into a stream.
var fileStream = xtraOpenFileDialog1.OpenFile();
using(StreamReader reader = new StreamReader(fileStream)) {
// ...
}
}
}
	點擊復制
VB.NET:
Imports System.IO Private Sub simpleButtonOpenFileDialog_Click(ByVal sender As Object, ByVal e As EventArgs) xtraOpenFileDialog1.InitialDirectory = "c:\" xtraOpenFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" If xtraOpenFileDialog1.ShowDialog() = DialogResult.OK Then ' Get the path of specified file. Dim filePath As String = xtraOpenFileDialog1.FileName ' Read the contents of the file into a stream. Dim fileStream = xtraOpenFileDialog1.OpenFile() Using reader As New StreamReader(fileStream) ' ... End Using End If End Sub
點擊復制

 QQ交談
QQ交談 在線咨詢
在線咨詢 
                 
                
 渝公網安備
            50010702500608號
渝公網安備
            50010702500608號
             
            
 客服熱線
客服熱線