DevExpress_常用控件03_GalleryControl

工具 返回到 『.Net/Win Form』

1.4 GalleryControl

控件可显示图像,同时让你将它们分类。

效果图:


例1:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraBars.Ribbon;
using DevExpress.Utils.Drawing;

namespace DXApplication_1
{
	public partial class GalleryContrlForm : DevExpress.XtraEditors.XtraForm
	{
		public GalleryContrlForm()
		{
			InitializeComponent();
		}

		private void GalleryContrlForm_Load(object sender, EventArgs e)
		{
			GalleryControl galleryControl = new GalleryControl();
			galleryControl.Dock = DockStyle.Fill;
			this.Controls.Add(galleryControl);

			Image im1 = Image.FromFile("C:\\Users\\teeking_scx\\source\\repos\\DXApplication_1\\imgs\\delete.png");
			Image im2 = Image.FromFile("C:\\Users\\teeking_scx\\source\\repos\\DXApplication_1\\imgs\\edit.png");
			Image im3 = Image.FromFile("C:\\Users\\teeking_scx\\source\\repos\\DXApplication_1\\imgs\\menu.png");
			Image im4 = Image.FromFile("C:\\Users\\teeking_scx\\source\\repos\\DXApplication_1\\imgs\\new.png");
			Image im5 = Image.FromFile("C:\\Users\\teeking_scx\\source\\repos\\DXApplication_1\\imgs\\search.png");
			Image im6 = Image.FromFile("C:\\Users\\teeking_scx\\source\\repos\\DXApplication_1\\imgs\\heart.png");

			galleryControl.Gallery.ItemImageLayout = ImageLayoutMode.ZoomInside;
			galleryControl.Gallery.ImageSize = new Size(120, 90);
			galleryControl.Gallery.ShowItemText = true;

			GalleryItemGroup group1 = new GalleryItemGroup();
			group1.Caption = "Anime";
			galleryControl.Gallery.Groups.Add(group1);


			GalleryItemGroup group2 = new GalleryItemGroup();
			group2.Caption = "Girl";
			galleryControl.Gallery.Groups.Add(group2);

			group1.Items.Add(new GalleryItem(im1, "Leon", ""));
			group1.Items.Add(new GalleryItem(im2, "Fate", ""));
			group1.Items.Add(new GalleryItem(im3, "未闻花名", ""));

			group2.Items.Add(new GalleryItem(im4, "Mathilda", ""));
			group2.Items.Add(new GalleryItem(im5, "Saber", ""));
			group2.Items.Add(new GalleryItem(im6, "面码", ""));
		}

		private void label1_Click(object sender, EventArgs e)
		{

		}
	}
}