- [DEVEXPRESS] Hướng dẫn bật tính năng Scroll Pixcel in Touch trên GridView
- [DEVEXPRESS] Hướng dẫn sử dụng TileBar viết ứng dụng duyệt hình ảnh Winform
- [DEVEXPRESS] Tô màu border TextEdit trên Winform
- [C#] Lấy dữ liệu từ Console Write hiển thị lên textbox Winform
- [C#] Hiển thị Progress bar trên Window Console
- [C#] Di chuyển control Runtime và lưu layout trên winform
- [SQLSERVER] Sử dụng hàm NULL IF
- [C#] Chia sẽ source code mã đi tuần bằng giao diện Winform
- [C#] Flash Window in Taskbar Winform
- Download và Giải nén tập tin File sử dụng Powershell
- [C#] Hướng dẫn cách lấy thông tin đăng nhập tài khoản và mật khẩu web browser trên windows
- [VB.NET] CRUD Thêm xóa sửa tìm kiếm Realtime FireBase
- [C#] Hiển thị thông báo Toast Message trong lập trình Winform
- [C#] Cấu hình định dạng ngày tháng, thời gian trên Windows cho ứng dụng Winform
- [C#] Rút gọn đường dẫn link url với TinyURL API
- [C#] Hướng dẫn cách bo tròn winform with Radius
- [C#] Chia sẽ class BackGroundOverlay Show Modal cho Winform
- [C#] Hướng dẫn Flip Image Winform
- [C#] Invoke là gì? cách sử dụng phương thức Invoke()
- [C#] Hướng dẫn chia sẽ file, folder từ ứng dụng sang Zalo Chat
[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!