본문 바로가기
C#/DevExpress

DevExpress / Winform XtraDialog로 로그인 화면 만들기.

by HyunS_ 2019. 6. 7.
728x90

XtraDialog로 로그인 화면 만들기 입니다.

 

LoginUserControl.cs 파일 입니다.

using System.Windows.Forms;

using DevExpress.XtraEditors;
using DevExpress.XtraLayout;

namespace WindowsFormsApp1
{
    /// <summary>
    /// 로그인 유저 컨트롤 클래스 입니다.
    /// </summary>
    public partial class LoginUserControl : XtraUserControl
    {
        // Constructor (Public)

        #region LoginUserControl() - 생성자 입니다.

        /// <summary>
        /// 생성자 입니다.
        /// </summary>
        public LoginUserControl()
        {
            InitializeComponent();

            LayoutControl layoutControl = new LayoutControl();

            layoutControl.Dock = DockStyle.Fill;

            TextEdit textLogin      = new TextEdit();
            TextEdit textPassword   = new TextEdit();
            CheckEdit checkEditKeep = new CheckEdit(){ Text = "Keep me Signed in" };

            SeparatorControl separatorControl = new SeparatorControl();

            layoutControl.AddItem(string.Empty, textLogin    ).TextVisible = false;
            layoutControl.AddItem(string.Empty, textPassword ).TextVisible = false;
            layoutControl.AddItem(string.Empty, checkEditKeep);

            this.Controls.Add(layoutControl);

            this.Height = 100;
            this.Dock   = DockStyle.Top;

        }

        #endregion
    }
}

 

MainForm.cs 파일 입니다.

using System;
using System.Windows.Forms;

using DevExpress.XtraEditors;

namespace WindowsFormsApp1
{
    /// <summary>
    /// 메인폼 클래스 입니다.
    /// </summary>
    public partial class MainForm : Form
    {
       
        // Constructor (Public)

        #region MainForm() - 생성자 입니다.

        /// <summary>
        /// 생성자 입니다.
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            this.simpleButton1.Click += simpleButton1_Click;

        }

        #endregion

        // Event Method (Private)
        #region simpleButton1_Click(sender, e) - 버튼 클릭시 동작합니다.

        /// <summary>
        /// 버튼 클릭시 동작합니다.
        /// </summary>
        /// <param name="sender">이벤트 발생자 입니다.</param>
        /// <param name="e">이벤트 인자 입니다.</param>
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            LoginUserControl myControl = new LoginUserControl();

            if(XtraDialog.Show(myControl, "Sign in", MessageBoxButtons.OKCancel) == DialogResult.OK)
            { 
            
            }
        }

        #endregion

    }
}
728x90

댓글