DevExpress_常用控件05_TileControl

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

1.6 TileControl控件

该控件是根据Windows 8的用户界面设计的,可以轻松地把各个控制块集成到窗体上。

1.   IndertBetweenGroups属性

控制两个Group之间的间距;

2.   该控件通过TileGroup添加Group;

该控件通过TileItems添加Item;

3、该控件通过TileControl.ItemClick事件执行选中的Item后执行的操作;


效果如下:


示例代码1:

  using DevExpress.XtraEditors;


  TileItem titleItem = new TileItem();

  tileControl1.Groups.Add(new TileGroup());

  tileControl1.Groups[0].Items.Add(titleItem);


示例代码2:

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;

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

		private void TitleControlForm_Load(object sender, EventArgs e)
		{
			TileItem tileItem = new TileItem();

			// First Frame - Image only
			TileItemFrame titleItemFrame = new TileItemFrame();
			// create 
			TileItemElement tileItemElement = new TileItemElement();
			Image img = Image.FromFile("C:\\Users\\teeking_scx\\source\\repos\\DXApplication_1\\imgs\\heart.png");
			tileItemElement.Image = img;
			tileItemElement.ImageAlignment = TileItemContentAlignment.MiddleCenter;
			// add 
			titleItemFrame.Elements.Add(tileItemElement);
			titleItemFrame.Elements[0].AnimateTransition = DevExpress.Utils.DefaultBoolean.True;

			// Second Frame - Text only
			TileItemFrame tileItemFrame2 = new TileItemFrame();
			// create another
			TileItemElement tileItemElement2 = new TileItemElement();
			
			tileItemElement2.Text = "<Size=+2><Color=Teal><b>未闻花名</b></Color></Size>";
			tileItemElement2.TextAlignment = TileItemContentAlignment.MiddleCenter;

			// add
			tileItemFrame2.Elements.Add(tileItemElement2);
			tileItemFrame2.Elements[0].AnimateTransition = DevExpress.Utils.DefaultBoolean.True;

			//Global Tile Item Settings
			tileItem.Frames.Add(titleItemFrame);
			tileItem.Frames.Add(tileItemFrame2);

			tileItem.Appearance.BackColor = System.Drawing.Color.Bisque;
			tileItem.Appearance.BackColor2 = System.Drawing.Color.SandyBrown;
			tileItem.Appearance.GradientMode = System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal;
			tileItem.Appearance.BorderColor = System.Drawing.Color.Bisque;
			tileItem.AllowHtmlText = DevExpress.Utils.DefaultBoolean.True;
			tileItem.FrameAnimationInterval = 2500;
			tileItem.IsLarge = true;

			// 
			TileGroup tileGroup = new TileGroup();
			tileGroup.Items.Add(tileItem);
			tileControl1.Groups.Add(tileGroup);
			
			// 
			tileItem.StartAnimation();
		}
	}
}