C# [C#] 纯文本查看 复制代码 //Create an XtraUserControl that represents a login form
public class LoginUserControl : XtraUserControl {
public LoginUserControl() {
LayoutControl lc = new LayoutControl();
lc.Dock = DockStyle.Fill;
TextEdit teLogin = new TextEdit();
TextEdit tePassword = new TextEdit();
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.Dock = DockStyle.Fill;
}
}
//Show an XtraUserControl-based login form inside a dialog
private void simpleButton1_Click(object sender, EventArgs e) {
LoginUserControl myControl = new LoginUserControl();
DevExpress.XtraEditors.XtraDialog.Show(myControl, "Sign in", MessageBoxButtons.OKCancel);
} VB.NET [Visual Basic .NET] 纯文本查看 复制代码 'create an XtraUserControl that represents a login form
Public Class LoginUserControl
Inherits XtraUserControl
Public Sub New()
Dim lc As New LayoutControl()
lc.Dock = DockStyle.Fill
Dim teLogin As New TextEdit()
Dim tePassword As New TextEdit()
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.Dock = DockStyle.Fill
End Sub
End Class
'show an XtraUserControl-based login form inside a dialog
Private Sub simpleButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim myControl As New LoginUserControl()
DevExpress.XtraEditors.XtraDialog.Show(myControl, "Sign in", MessageBoxButtons.OKCancel)
End Sub 要在设计时添加XtraUserControls,请右键单击您的项目,然后选择 "Add DevExpress Item" 选项,这将调用Template Gallery,该库允许您添加空白XtraUserControls和DevExpress表单以及基于模板的表单。 与标准WinForms UserControl相比,XtraUserControl具有以下优点: - 最终用户可以在悬停时滚动XtraUserControl内容,而无需首先关注它;
- 与布局和数据布局控件组件通信来传递正确的控件大小;
- 允许您直接从承载此容器的表单(可视继承)中为XtraUserControl(或其子)内部的控件使用智能标记和Designer对话框;
- 支持DevExpress皮肤,并确保整个应用程序的外观一致性。
DevExpress技术交流群3:700924826 欢迎一起进群讨论
|