彩票走势图

logo DevExpress WinForm中文手册

XtraDialog


立即下载DevExpress WinForms

XtraDialog是一个替代标准对话框的消息框。与标准对话框一样,它允许您在其客户端区域显示控件(例如,UserControl)和按钮集,然而,与标准对话框不同的是,它支持DevExpress皮肤来应用一致的外观。例如,下图显示了一个与应用程序主题不匹配的标准对话框。

xtradialog

第二幅图显示了使用XtraDialog的同一个应用程序。

xtradialog

要显示对话框,请调用静态XtraDialog.Show方法。此方法的参数允许您指定在其客户端区域显示哪个控件,指定对话框的标题,并添加预定义的按钮:

下面的代码调用一个XtraDialog,显示一个带有自定义控件的UserControl(两个TextEdit控件和一个CheckEdit控件),以及OK和Cancel按钮:

xtradialog示例

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

点击复制

扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP