- [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 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!