文檔半島外圍網上直營>>DevExpress WinForm中文手冊>>XtraDialog
                XtraDialog
XtraDialog是一個替代標準對話框的消息框。與標準對話框一樣,它允許您在其客戶端區域顯示控件(例如,UserControl)和按鈕集,然而,與標準對話框不同的是,它支持DevExpress皮膚來應用一致的外觀。例如,下圖顯示了一個與應用程序主題不匹配的標準對話框。
 
 
第二幅圖顯示了使用XtraDialog的同一個應用程序。
 
 
要顯示對話框,請調用靜態XtraDialog.Show方法。此方法的參數允許您指定在其客戶端區域顯示哪個控件,指定對話框的標題,并添加預定義的按鈕:
下面的代碼調用一個XtraDialog,顯示一個帶有自定義控件的UserControl(兩個TextEdit控件和一個CheckEdit控件),以及OK和Cancel按鈕:
 
 
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraLayout;
using DevExpress.XtraPrinting.Export;
namespace WindowsFormsApp1 {
public partial class Form3 : Form {
public Form3() {
InitializeComponent();
}
private void simpleButton1_Click(object sender, EventArgs e) {
LoginUserControl myControl = new LoginUserControl();
if(XtraDialog.Show(myControl, "Sign in", MessageBoxButtons.OKCancel) == DialogResult.OK) {
/*
* string login = myControl.Login;
* string password = myControl.Password;
*/
}
}
}
public class LoginUserControl : XtraUserControl {
TextEdit teLogin;
TextEdit tePassword;
public LoginUserControl() {
LayoutControl lc = new LayoutControl();
lc.Dock = DockStyle.Fill;
this.teLogin = new TextEdit();
this.tePassword = new TextEdit();
tePassword.Properties.UseSystemPasswordChar = true;
CheckEdit ceKeep = new CheckEdit() { Text = "Keep me signed in" };
lc.AddItem(String.Empty, teLogin).TextVisible = false;
lc.AddItem(String.Empty, tePassword).TextVisible = false;
lc.AddItem(String.Empty, ceKeep);
this.Controls.Add(lc);
this.Height = 100;
this.Dock = DockStyle.Top;
}
public string Login {
get { return teLogin.Text; }
}
public string Password {
get { return tePassword.Text; }
}
}
}
	點擊復制
VB.NET:
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraEditors
Imports DevExpress.XtraLayout
Imports DevExpress.XtraPrinting.Export
Namespace WindowsFormsApp1
Partial Public Class Form3
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub simpleButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim myControl As New LoginUserControl()
If XtraDialog.Show(myControl, "Sign in", MessageBoxButtons.OKCancel) = System.Windows.Forms.DialogResult.OK Then
' string login = myControl.Login;
' string password = myControl.Password;
End If
End Sub
End Class
Public Class LoginUserControl
Inherits XtraUserControl
Private teLogin As TextEdit
Private tePassword As TextEdit
Public Sub New()
Dim lc As New LayoutControl()
lc.Dock = DockStyle.Fill
Me.teLogin = New TextEdit()
Me.tePassword = New TextEdit()
tePassword.Properties.UseSystemPasswordChar = True
Dim ceKeep As New CheckEdit() With {.Text = "Keep me signed in"}
lc.AddItem(String.Empty, teLogin).TextVisible = False
lc.AddItem(String.Empty, tePassword).TextVisible = False
lc.AddItem(String.Empty, ceKeep)
Me.Controls.Add(lc)
Me.Height = 100
Me.Dock = DockStyle.Top
End Sub
Public ReadOnly Property Login() As String
Get
Return teLogin.Text
End Get
End Property
Public ReadOnly Property Password() As String
Get
Return tePassword.Text
End Get
End Property
End Class
End Namespace
	點擊復制

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