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;
}
}