Hello Steve,
Thank you for contacting us.
There was an issue in the layout of
RadPanorama which was causing such exception when you dynamically add items. You can workaround it by suspending the layout of the
RadPanoramaElement while adding tiles. The issue is no longer present in the latest version.
I have also noticed a small issue in the sample code you have posted. Please note that the
RadPanorama.RowsCount property sets the number of rows when you are not using groups. In grouped view, each group has its own
RowsCount property and in your case you should use
tileGroupElement1.RowsCount.
The following code snippet demonstrates how to overcome the above mentioned issue:
public
Form1()
{
InitializeComponent();
this
.tileGroupElement1.RowsCount = 5;
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
this
.radPanorama1.PanoramaElement.SuspendLayout(
true
);
foreach
(
string
img
in
Directory.GetFiles(@
"C:\images"
,
"*.png"
))
{
AddNewImageTile(img);
}
this
.radPanorama1.PanoramaElement.ResumeLayout(
true
,
true
);
}
private
void
AddNewImageTile(
string
ImagePath)
{
if
(File.Exists(ImagePath))
{
RadTileElement newTile =
new
RadTileElement();
newTile.AutoSize =
true
;
newTile.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.Auto;
newTile.GradientStyle = Telerik.WinControls.GradientStyles.Linear;
newTile.Image = Image.FromFile(ImagePath).GetThumbnailImage(64, 64,
null
, IntPtr.Zero);
newTile.ImageAlignment = System.Drawing.ContentAlignment.BottomLeft;
newTile.Padding =
new
System.Windows.Forms.Padding(15);
newTile.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage;
newTile.Row = tileGroupElement1.Items.Count %
this
.tileGroupElement1.RowsCount;
newTile.Column = tileGroupElement1.Items.Count /
this
.tileGroupElement1.RowsCount;
this
.tileGroupElement1.Items.Add(newTile);
}
}
A bit offtopic, I would like to remind you that your trial support package has expired. If you would like to continue receiving support from us, you will have to consider a purchase of some of the licenses that we offer. You can find the available options at this URL -
http://www.telerik.com/purchase.aspx. These licenses come with Dev priority support where the tickets should be answered in a guaranteed period of time. Shortly said, we will provide you with quicker responses.
Hope this helps. Feel free to ask if you have any further questions.
All the best,
Ivan Todorov
the Telerik team