First, turn your "template" into a custom control, for the sake of simplicity, I'm going to refer to it as a MyControl
that has a MyData
property.
Now, let's say you need your horizontally scrolling Panel
, with a MyControl
per MyData
, you could do:
IEnumerable<MyData> = GetMyData();
foreach( MyData thisData in GetMyData() )
{
MyControl thisControl = new MyControl();
thisControl.Dock = Left; // Or right, if you prefer
thisControl.Value = thisData;
panel1.Controls.Add( thisControl ); // Where panel1 is a Panel that represents the container for the scrolling-ness
}
Obviously, you'll want to tweak that to fit your types, maybe set a few other properties as appropriate.