I have a Devexpress winforms GridView
that I would like to convert to a TileView
. Here is my current GridView
at runtime:
This GridView is populated using a List datasource and it works fine. I convert the GridView
to a TileView
using the Designer:
After successfully converting the GridView, I tried to run the App, It shows the right number of records, but it is blank:
Am I missing anything? Here is a code to populate the grids:
using (var sovDB = new MyEntities())
{
gridControl1.BeginUpdate();
tileView1.Columns.Clear();
gridControl1.DataSource = null;
var query = (from b in sovDB.Palletes
join ipc in sovDB.IPCDisplays on b.DisplayNo equals ipc.DisplayNo
orderby b.PalleteID
select new
{
PalletNo = b.PalleteNumber,
Packs = b.CurrentPackCount,
Mass = b.CurrentPackWeight + " Kg"
}).ToList();
gridControl1.DataSource = query;
gridControl1.EndUpdate();
}
You need to create TileViewItemElement
objects that will correspond to columns of DataSource using the TileViewItemElement.Column
property like this :
tileView1.TileTemplate.Add(new TileViewItemElement { Column = tileView1.Columns["PalletNo"], TextAlignment = TileItemContentAlignment.TopCenter });
tileView1.TileTemplate.Add(new TileViewItemElement { Column = tileView1.Columns["Packs"], ImageAlignment = TileItemContentAlignment.TopLeft });
tileView1.TileTemplate.Add(new TileViewItemElement { Column = tileView1.Columns["Mass"], ImageAlignment = TileItemContentAlignment.BottomRight });
You can also configure the TileTemplate
by Design Mode like this :