MetroTilePanel自动生成metroTileItem

using DevComponents.DotNetBar.Metro;
using DevComponents.DotNetBar;
using System.Drawing;

public void ItemContainerBinding(ItemContainer ic, string sql, string strColumnName, string strColumnValue)
        {
            ic.Refresh();
            ic.SubItems.Clear();

            DataTable dt = new SQLHelper().DBDataTable(sql);//将查询出来的先放在DataTable
            if (dt.Rows.Count <= 0)
                return;

            MetroTileItem[] metroItem = new MetroTileItem[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)//自动生成
            {
                metroItem[i] = new MetroTileItem();
                metroItem[i].Text = dt.Rows[i][strColumnName].ToString();
                if (strColumnValue != string.Empty)
                {
                    metroItem[i].Tag = dt.Rows[i][strColumnValue].ToString();
                }
                metroItem[i].TileStyle.TextAlignment = eStyleTextAlignment.Center;
                metroItem[i].TileStyle.TextAlignment = eStyleTextAlignment.Center;
                metroItem[i].TileStyle.BackColor2 = Color.Silver;
                metroItem[i].TileStyle.BackColor = Color.Silver;
                metroItem[i].Click += metroTileItem_Click;
                metroItem[i].TileSize = new System.Drawing.Size(100, 50);
            }
            ic.SubItems.AddRange(metroItem);
            ic.Refresh();
        }

        private void metroTileItem_Click(object sender, EventArgs e)
        {
            if (((MetroTileItem)sender).TileStyle.BackColor == Color.SkyBlue)
            {
                ((MetroTileItem)sender).TileStyle.BackColor = Color.Silver;
                ((MetroTileItem)sender).TileStyle.BackColor2 = Color.Silver;
            }
            else
            {
                ((MetroTileItem)sender).TileStyle.BackColor = Color.SkyBlue;
                ((MetroTileItem)sender).TileStyle.BackColor2 = Color.SkyBlue;
            }
        }





代码介绍 MetroForWinForm(win8风格模版) using System; using System.Drawing; using System.Globalization; using System.Windows.Forms; using MetroFramework.Forms; namespace MetroFramework.Demo { public partial class MainForm : MetroForm { public MainForm() { InitializeComponent(); metroStyleManager.Theme = MetroThemeStyle.Default; metroStyleManager.Style = MetroColorStyle.Teal; } private void metroTileSwitch_Click(object sender, EventArgs e) { var m = new Random(); int next = m.Next(0, 13); metroStyleManager.Style = (MetroColorStyle)next; } private void metroTile1_Click(object sender, EventArgs e) { metroStyleManager.Theme = metroStyleManager.Theme == MetroThemeStyle.Light ? MetroThemeStyle.Dark : MetroThemeStyle.Light; } private void metroButton1_Click(object sender, EventArgs e) { MetroTaskWindow.ShowTaskWindow(this, "SubControl in TaskWindow", new TaskWindowControl(), 10); } private void metroButton2_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "Do you like this metro message box?", "Metro Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk); } private void metroButton5_Click(object sender, EventArgs e) { metroContextMenu1.Show(metroButton5, new Point(0, metroButton5.Height)); } private void metroButton6_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample MetroMessagebox `OK` only button", "MetroMessagebox", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void metroButton10_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample MetroMessagebox `OK` and `Cancel` button", "MetroMessagebox", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } private void metroButton7_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample MetroMessagebox `Yes` and `No` button", "MetroMessagebox", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } private void metroButton8_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample MetroMessagebox `Yes`, `No` and `Cancel` button", "MetroMessagebox", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); } private void metroButton11_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample MetroMessagebox `Retry` and `Cancel` button. With warning style.", "MetroMessagebox", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning); } private void metroButton9_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample MetroMessagebox `Abort`, `Retry` and `Ignore` button. With Error style.", "MetroMessagebox", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error); } private void metroButton12_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample `default` MetroMessagebox ", "MetroMessagebox"); } private void metroButton4_Click(object sender, EventArgs e) { var testform = new TestForm1(); testform.ShowDialog(); } private void metroButton4_Click_1(object sender, EventArgs e) { metroTextBox2.Focus(); } } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值