- [VB.NET] Chia sẻ source code lịch âm dương và hẹn lịch nhắc việc
- [C#] Hướng dẫn đọc thông số thiết bị Thiết bị kiểm tra Pin (HIOKI BATTERY HiTESTER BT3562)
- [VB.NET] Hướng dẫn giải captcha sử dụng dịch vụ AZCaptcha API trên winform
- [C#] Hướng dẫn chứng thực đăng nhập ứng dụng bằng vân tay (Finger Print) trên máy tính
- [C#] Color Thief cách xuất màu sắc thiết kế từ hình ảnh
- [C#] Cách tạo bản quyền và cho phép dùng thử ứng dụng Winform
- [C#] Hướng dẫn sử dụng trình duyệt web Chrome convert HTML sang tập tin file PDF
- [C#] Kết nôi điện thoại Android, IOS với App Winform via Bluetooth
- [DATABASE] Cách query cộng trừ dồn dần trong Sqlserver
- [C#] Thiết kế ứng dụng Console đẹp với thư viện Spectre.Console
- [C#] Thiết kế ứng dụng Single Instance và đưa ứng dụng lên trước nếu kiểm tra ứng dụng đang chạy
- [C#] Giới thiệu JSON Web Token và cách đọc chuỗi token
- [C#] Cách tăng giảm font chữ tất cả các control trên winform
- [DEVEXPRESS] Tích hợp chức năng Tìm kiếm Search vào CheckedComboboxEdit
- [C#] Gởi email Metting Calendar Reminder kèm nhắc thời gian lịch họp
- [C#] Tìm kiếm xem danh sách từ khóa có tồn tại trong đoạn văn bản hay không
- [C#] Thiết kế giao diện ứng dụng trên Console sử dụng thư viện Terminal.Gui
- [C#] Hướng dẫn tạo mã VietQR Payment API Winform
- [C#] Sử dụng thư viện BenchmarkDotNet đo hiệu năng của hảm Method
- [DEVEXPRESS] Tìm kiếm không dấu tô màu highlight có dấu trên C# Winform
[DEVEXPRESS] Hướng dẫn sử dụng Flyout Dialog trên lập trình C#, winform
Xin chào các bạn, bài viết hôm nay mình sẻ tiếp tục hướng dẫn các bạn cách sử dụng Flyout Dialog trên lập trình c#, Winform DevExpress.
[DEVEXPRESS] How to Using Flyout Dialog C#, Winform
Ở bài này, mình sẽ demo một ứng dụng hiển thị Form Login bằng cách sử dụng Flyout Dialog của Devexpress.
Giao diện login mình thiết kế như hình bên dưới:
Video step by step sử dụng Flyout Dialog C#:
Bạn nào thấy bài viết có ích, ủng hộ cho mình một sub đăng ký kênh nhé các bạn. <3
Đầu tiên, các bạn tạo cho mình một class với tên: VBFlyoutDialog.cs
using DevExpress.XtraBars.Docking2010.Customization;
using DevExpress.XtraBars.Docking2010.Views.WindowsUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace VBCustomFlyoutDialog
{
public class VBFlyoutDialog : FlyoutDialog
{
public VBFlyoutDialog(Form form, FlyoutAction action, Control userControl): base(form, action)
{
this.Properties.HeaderOffset = 0;
this.Properties.Alignment = System.Drawing.ContentAlignment.MiddleCenter;
this.Properties.Style = FlyoutStyle.Popup;
this.FlyoutControl = userControl;
}
public static DialogResult ShowFormPopup(Form form, FlyoutAction action, Control userControl)
{
var vbFlyout = new VBFlyoutDialog(form, action, userControl);
return vbFlyout.ShowDialog();
}
}
}
Tiếp đến, các bạn sẽ tạo một UserControl Form Login như hình bên dưới:
Ở usercontrol này, các bạn tạo cho mình 3 control gồm các thông tin: User Name, Password, is Remember.
Code uc_LoginForm.cs
:
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace VBCustomFlyoutDialog
{
public partial class uc_LoginForm : DevExpress.XtraEditors.XtraUserControl
{
public uc_LoginForm(Login login)
{
InitializeComponent();
txtUsername.DataBindings.Add("Text", login, "UserName");
txtPassword.DataBindings.Add("Text", login, "Password");
chkRemember.DataBindings.Add("Checked", login, "isRemember");
}
}
}
Tiếp đến các bạn, tạo một class Login.cs
namespace VBCustomFlyoutDialog
{
public class Login
{
public string UserName { get; set; }
public string Password { get; set; }
public bool isRemember { get; set; }
}
}
Và cuối cùng, mình sẽ thiết kế Form Main để gọi Dialog Form Login, khi đăng nhập các thông tin sẽ trả dữ liệu về cho Form Chính.
Ở đây, chúng ta sẽ sử dụng kỹ thuật DataBinding để lấy dữ liệu thông tin của Form Login Dialog.
Source code Form1.cs
:
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;
namespace VBCustomFlyoutDialog
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
public Form1()
{
InitializeComponent();
}
private void btnLogin_Click(object sender, EventArgs e)
{
var login = new Login();
var dlg = VBFlyoutDialog.ShowFormPopup(this, null, new uc_LoginForm(login));
if(dlg == DialogResult.OK)
{
lbl_username.Text = login.UserName;
lblPassword.Text = login.Password;
lblRemember.Text = login.isRemember.ToString();
}
}
}
}
Thanks for watching!