- [C#] Hướng dẫn convert HTML code sang PDF File trên NetCore 7 Winform
- [C#] Hướng dẫn viết ứng dụng chat với Gemini AI Google Winform
- Hướng dẫn khóa file bằng nhiều process id, không cho xóa tập tin
- Hướng dẫn cách tạo Product Id cho ứng dụng phần mềm XXXXX-XXXXX-XXXXX-XXXXX
- [SQLSERVER] Hướng dẫn tạo script sql từ ứng dụng Sqlserver management Studio
- [C#] Hướng dẫn sử dụng thư viện AutoITx lấy id và password Ultraviewer trên winform
- [VB.NET] Hướng dẫn lấy thông tin tài khoản đăng nhập windows và khởi động lại ứng dụng ở chế độ Administrator
- [C#] Sử dụng thư viện Polly gửi lại request api khi request bị lỗi hay rớt mạng
- [DEVEXPRESS] Chia sẻ source code tạo báo cáo report in tem nhãn label trên C# winform
- [DEVEXPRESS] Hướng dẫn vẽ biểu đồ Bar Chart trên Winform
- [C#] Tạo form đăng nhập và đăng ký với hiệu ứng Sliding Animation Effect
- [C#] Hướng dẫn tạo thanh toán đơn hàng qua mã vạch VietQR sử dụng API PayOS hoàn toàn miễn phí
- [C#] Hướng dẫn ghi log ra RichTextBox giống Console trên Winform sử dụng thư viện Serilog
- [C#] Hướng dẫn cách tạo mã QR Code trên file Excel
- [VB.NET] Gởi tin nhắn và file đính kèm qua ứng dụng gởi tin nhắn Whats App
- [C#] Viết ứng dụng Auto Fill list Textbox from clipboard Winform
- [TOOL] Chia sẻ phần mềm thay đổi thông tin cấu hình máy tính
- [C#] Hướng dẫn Export dữ liệu ra file Microsoft Word Template
- [C#] Chia sẻ source code tool kiểm tra domain website
- [C#] Hướng dẫn tạo file PDF sử dụng thư viện QuestPDF
[DEVEXPRESS] Hướng dẫn nhúng Usercontrol vào hộp thoại XtraDialog
Xin chào các bạn, bài viết sẻ hướng dẫn các bạn cách sử dụng XtraDialog để mở một xtraUserControl như một Dialog Result trong Devexpress C#.
[DEVEXPRESS] Using XtraDialog Usercontrol C#
Giao diện demo ứng dụng sử dụng XtraEditor:
Các bạn thấy ở hình trên cái form show Dialog là một UserControl, và mình nhét nó vào Xtradialog
Cái XtraDialog này hoạt động giống thằng XtraMessageDialog trong Devexpress
Đầu tiên các bạn tạo 1 class StudentItem.cs
Dùng để gởi nó vào contructor của userControl, để khi chúng ta bấm OK, sẽ trả dữ liệu về qua phương thức DataBindding.
- File StudentItem.cs
namespace UsingXtraDialog
{
public class StudentItem
{
public int ID { set; get; }
public string Name { set; get; }
public string Address { set; get; }
}
}
2. File uc_student usercontrol:
namespace UsingXtraDialog
{
public partial class uc_Student : DevExpress.XtraEditors.XtraUserControl
{
public uc_Student(StudentItem studentItem)
{
InitializeComponent();
txt_id.DataBindings.Add("EditValue", studentItem, "ID");
txtName.DataBindings.Add("EditValue", studentItem, "Name");
txtAddress.DataBindings.Add("EditValue", studentItem, "Address");
}
}
}
3. Form Main
namespace UsingXtraDialog
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
public Form1()
{
InitializeComponent();
}
private void btn_showDialog_Click(object sender, EventArgs e)
{
var studentItem = new StudentItem();
var myControl = new uc_Student(studentItem);
DialogResult result = DevExpress.XtraEditors.XtraDialog.Show(this, myControl, "Demo XtraDialog - https://laptrinhvb.net", MessageBoxButtons.OKCancel);
if (result == DialogResult.OK)
{
var id = studentItem.ID;
var name = studentItem.Name;
var address = studentItem.Address;
var infoStudent = $"ID: {id}\r\nName: {name}\r\nAddress: {address}";
rtf_result.Text = infoStudent;
}
}
}
}
Thanks for watching!