- [DEVEXPRESS] Chia sẻ code các tạo report in nhiều hóa đơn trên XtraReport C#
- [POWER AUTOMATE] Hướng dẫn gởi tin nhắn zalo từ file Excel - No code
- [C#] Chia sẻ code lock và unlock user trong domain Window
- [SOFTWARE] Giới thiệu bộ phần mềm tính Kết Cấu Thép HatteSale, Mộng Đơn, Dầm, Sàn, Móng Cọc, Vách, Xà Gồ, Tính Tải Trọng
- [DEVEXPRESS] Vẽ Biểu Đồ Stock Chứng Khoán - Công Cụ Thiết Yếu Cho Nhà Đầu Tư trên Winform
- [C#] Hướng dẫn bảo mật ứng dụng 2FA (Multi-factor Authentication) trên Winform
- [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
[DEVEXPRESS] Hướng dẫn sử dụng ListBox Template 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 ListBox Template trên Devexpress C#, Winform.
[DEVEXPRESS] How to using listbox template c#, winform
Dưới đây, là giao diện demo ứng dụng:
Ở bài viết nay, mình sẽ tích hợp thêm Button Context ở góc bên phải listbox, các bạn có thể thực hiện chi tiết từng bước ở video bên dưới.
Full source code C#:
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.Windows.Forms;
namespace ListBoxTemplate
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
public Form1()
{
InitializeComponent();
}
public class Employee
{
public string firstname { get; set; }
public string lastname { get; set; }
public string url { get; set; }
public Image photo {
get {
var picture = new PictureBox();
picture.Load(url);
return picture.Image;
}
}
public string address { get; set; }
}
public List<Employee> GetEmployees()
{
var listEmployee = new List<Employee>();
listEmployee.Add(new Employee { firstname = "Cristiano", lastname = "Ronaldo", url = "ronaldo.jpg", address = "Manchester United FC" });
listEmployee.Add(new Employee { firstname = "Lionel", lastname = "Messi", url = "messi.jpg", address = "PSG FC" });
listEmployee.Add(new Employee { firstname = "Erling", lastname = "Haaland", url = "halland.jpg", address = "Borussia Dortmund FC" });
listEmployee.Add(new Employee { firstname = "Romelu", lastname = "Lukaku", url = "lukaku.jpg", address = "Chelsea FC" });
listEmployee.Add(new Employee { firstname = "Robert", lastname = "Lewandowski", url = "lewandowski.jpg", address = "Bayern München FC" });
listEmployee.Add(new Employee { firstname = "Neymar", lastname = "da Silva Santos Júnior", url = "neymar.jpg", address = "PSG FC" });
listEmployee.Add(new Employee { firstname = "Antoine", lastname = "Griezmann", url = "Griezmann.jpg", address = "Alectico Madrid FC" });
listEmployee.Add(new Employee { firstname = "Mohamed", lastname = "Salad", url = "salah.png", address = "Liverpool FC" });
listEmployee.Add(new Employee { firstname = "Kevin", lastname = "De Bruyne", url = "kevin.jpg", address = "Manchester City FC" });
listEmployee.Add(new Employee { firstname = "Kylian", lastname = "Mbappé", url = "Kylian.jpg", address = "PSG FC" });
return listEmployee;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void simpleButton1_Click(object sender, EventArgs e)
{
listBoxControl1.DataSource = GetEmployees();
}
private void listBoxControl1_ContextButtonClick(object sender, DevExpress.Utils.ContextItemClickEventArgs e)
{
var data = e.DataItem as Employee;
XtraMessageBox.Show(data.firstname + " " + data.lastname + Environment.NewLine + data.address);
}
}
}
Thanks for watching!
>> Các em nhớ chia sẻ cho Thầy đi