- [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 WinExplorer View trong GridView để hiển thị hình ảnh
Xin chào các bạn, bài viết hôm nay mình sẽ hướng dẫn các bạn sử dụng WinExplorer View trong Gridview của Devexpress.
[C#] Hướng dẫn sử dụng layout WinExplorer trong GridView của Devexpress
Trong GridView của Devexpress, hỗ trợ cho chúng ta hiển thị dữ liệu dưới các dạng layout rất phong phú: CardView
, TileView
, LayoutView
, GridBandView
...
Hôm nay, mình sẽ hướng dẫn các bạn sử dụng layout WinExplorer View để hiển thị danh sách hình ảnh.
Nếu bạn nào đang viết ứng dụng dùng để xem hình ảnh thì Layout View này sẽ giúp bạn hiển thị dễ dàng.
Trong WinExploer View cho phép chúng ta xem dữ liệu dưới các kiểu sau: Content, ExtraLarge, Large, Medium, Small, Title, List...
Giúp chúng ta xem hiển thị hình ảnh hoặc folder giống Windows Explorer của Windows.
Dưới đây là hình ảnh demo của ứng dụng đang hiển thị ở chế độ Large:
Xem hình ảnh ở chế độ small:
Hoặc hiển thị ở chế độ ExtraLarge
Souce code WinExplorer trong GridView C#:
using DevExpress.Utils;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid.Views.WinExplorer;
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 LoadImageAsyncToGridView
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
BindingList<PictureObject> list = new BindingList<PictureObject>();
for (int i = 0; i <= 30; i++)
{
list.Add(new PictureObject("Mecedes Ben", @"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQaIzJkKkVrCzTKRongBp4qXBB8FBfPXGCo9U3oLqd6VId9P7mi9g"));
list.Add(new PictureObject("Honda Civic", @"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTCo7JwSjLKhhnDbQmpuJm4BBG0tm5VVHw9eN04SFsVo5kWZyia"));
list.Add(new PictureObject("Ferari", @"https://leasecar.uk/images/main/cars/2/2/87467/xnew-evoque.jpeg.pagespeed.ic.5b-LT79dVc.jpg"));
list.Add(new PictureObject("Toyota", @"https://imgct2.aeplcdn.com/img/800x600/car-data/big/dc-avanti-default-image.png-version201904181821.png?v=31"));
list.Add(new PictureObject("Hyndai", @"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTzSTo9keosxkDB18KNDcc0SQx9V00QJJrc4je_uE9OCEJzce_9"));
list.Add(new PictureObject("Kia Morning", @"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKfzGiq4ftPP4gJKsDdFcaheDWk-ou75_3IYuXrHxqWrBRX-zdmQ"));
list.Add(new PictureObject("Lampogini", @"https://imgct2.aeplcdn.com/img/800x600/car-data/big/ferrari-488-gtb-image-11352.png?v=31"));
list.Add(new PictureObject("Ducati", @"https://imgct2.aeplcdn.com/img/800x600/car-data/big/ferrari-portofino-image-14428.png?v=31"));
}
winExplorerView1.OptionsView.AnimationType = DevExpress.XtraGrid.Views.Base.GridAnimationType.AnimateAllContent;
gridControl1.DataSource = list;
list.ListChanged += (s, args) =>
{
if (args.PropertyDescriptor.Name == "Image")
winExplorerView1.LayoutChanged();
};
}
public class PictureObject : INotifyPropertyChanged
{
public string Name { get; set; }
public Image Image { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public PictureObject(string name, string url)
{
Name = name;
Image = ResourceImageHelper.CreateImageFromResources("DevExpress.XtraEditors.Images.loading.gif", typeof(BackgroundImageLoader).Assembly);
BackgroundImageLoader bg = new BackgroundImageLoader();
bg.Load(url);
bg.Loaded += (s, e) =>
{
Image = bg.Result;
if (!(Image is Image)) Image = ResourceImageHelper.CreateImageFromResources("DevExpress.XtraEditors.Images.Error.png", typeof(BackgroundImageLoader).Assembly);
PropertyChanged(this, new PropertyChangedEventArgs("Image"));
bg.Dispose();
};
}
}
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.DataSource = Enum.GetValues(typeof(WinExplorerViewStyle));
}
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
string value = comboBox1.Text;
switch (value)
{
case "Content":
winExplorerView1.OptionsView.Style = WinExplorerViewStyle.Content;
break;
case "Default":
winExplorerView1.OptionsView.Style = WinExplorerViewStyle.Default;
break;
case "ExtraLarge":
winExplorerView1.OptionsView.Style = WinExplorerViewStyle.ExtraLarge;
break;
case "Large":
winExplorerView1.OptionsView.Style = WinExplorerViewStyle.Large;
break;
case "List":
winExplorerView1.OptionsView.Style = WinExplorerViewStyle.List;
break;
case "Medium":
winExplorerView1.OptionsView.Style = WinExplorerViewStyle.Medium;
break;
case "Small":
winExplorerView1.OptionsView.Style = WinExplorerViewStyle.Small;
break;
case "Tiles":
winExplorerView1.OptionsView.Style = WinExplorerViewStyle.Tiles;
break;
default:
break;
}
}
}
}
Thanks for watching!