Dynamic Panorama Controls

17 posts, 0 answers
  1. Gerhard
    Gerhard avatar
    4 posts
    Member since:
    Jan 2012

    Posted 10 Feb 2012 Link to this post

    I have a folder with shortcuts in witch I use to build my menu in the panorama control. When I break the code it shows all the shortcuts are in the control, but only the last one shows.
  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 15 Feb 2012 Link to this post

    Hi Gerhard,

    Thank you for your question.

    Most probably, your tiles are all set to appear in the first cell, they stack over each other and only the last one remains visible. The RadPanorama control arranges its tiles in a GridLayout panel and each tile can be set with a column and row in which it should appear. The following example demonstrates how to fill RadPanorama programatically with having the items properly arranged:
    for (int i = 0; i < 30; i++)
    {
        RadTileElement tile = new RadTileElement();
        tile.Text = "Item " + i;
        tile.Row = i % this.radPanorama1.RowsCount;
        tile.Column = i / this.radPanorama1.RowsCount;
     
        this.radPanorama1.Items.Add(tile);
    }

    I hope this will help you. Please let me know if you need further assistance.

    Kind regards,
    Ivan Todorov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Steve
    Steve avatar
    3 posts
    Member since:
    Feb 2012

    Posted 27 Jun 2012 Link to this post

    Hiya,

    I am using the above proposed approach to dynamically add tiles to a TileGroupElement in a Panorama control. When the form loads I iterate a folder to a get all images and call the following code to add new tiles, which works as expected:

    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 = this.GetThumbnail(ImagePath);
            newTile.ImageAlignment = System.Drawing.ContentAlignment.BottomLeft;
            newTile.Padding = new System.Windows.Forms.Padding(15);
            newTile.Size = new System.Drawing.Size(300, 250);
            newTile.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage;
            //newTile.Text = ImagePath;
             
            newTile.Row = tileGroupElement1.Items.Count % this.radPanorama1.RowsCount;
            newTile.Column = tileGroupElement1.Items.Count / this.radPanorama1.RowsCount;
     
            newTile.Click += new System.EventHandler(carouselItem_Click);
            this.tileGroupElement1.Items.Add(newTile);             
             
        }
    }

     

    However, when I invoke the same function lets say on a button click, i can see a new tile being added to the TileGroupElement, however at the same time the following error is being raised:

     

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.
     
    ************** Exception Text **************
    System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
       at System.ThrowHelper.ThrowArgumentOutOfRangeException()
       at Telerik.WinControls.Layouts.GridLayout.MeasureElements()
       at Telerik.WinControls.Layouts.GridLayout.MeasureOverride(SizeF availableSize)
       at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
       at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
       at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
       at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayoutCallback(ILayoutManager manager)

    the error is only raised when a new column is created to add the new tile. is there anything else that needs configuring for the TileGroupElement ?
    i am using RadControls version 2012.2.608.40.

  5. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 29 Jun 2012 Link to this post

    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
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  6. Steve
    Steve avatar
    3 posts
    Member since:
    Feb 2012

    Posted 29 Jun 2012 Link to this post

    Ivan,

    Thanks for the reply.
    According to my account I still have support subscriptions until next year - please can you contact me outside of the forums to sort that out?

    Thanks
    Steve
  7. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 03 Jul 2012 Link to this post

    Hi Steve,

    Indeed, you have a valid license until next year. The notification of the expired license is concerning the owner of this thread - Gerhard. Please excuse me for my mistake and for any inconvenience caused.

    Should you have any future questions, do not hesitate to contact us.

    All the best,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  8. Antz
    Antz avatar
    5 posts
    Member since:
    Nov 2012

    Posted 14 Feb 2013 Link to this post

    Dear Ivan Todorov,

    I have question for this issue too. How about VB code to add Group,Tile Item and event click for Panorama Controls dynamically.
    May you give me a sample code for this issue.
    Thank you so much..

    Best Regards.
  9. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 15 Feb 2013 Link to this post

    Hello Antz,

    The following code demonstrates how to add groups and tiles via code and also how to subscribe to each tile's Click event:
    Public Class Form1
     
        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Me.RadPanorama1.ShowGroups = True
            For index = 1 To 10
     
                Dim group As New TileGroupElement
                Me.RadPanorama1.Groups.Add(group)
                group.RowsCount = 3
                group.Text = "Group " & index
     
                For j As Integer = 0 To 12
                    Dim tile As New RadTileElement()
                    tile.Text = "Item " & j
                    tile.Row = j Mod group.RowsCount
                    tile.Column = j \ group.RowsCount
                    group.Items.Add(tile)
     
                    AddHandler tile.Click, AddressOf tile_Click
                Next
     
            Next
     
        End Sub
     
        Private Sub tile_Click(sender As Object, e As EventArgs)
            Dim tile = CType(sender, RadTileElement)
            RadMessageBox.Show(tile.Text & " was clicked")
        End Sub
     
    End Class

    I hope you find it useful. If you have any other questions, feel free to ask.

    All the best,
    Ivan Todorov
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  10. Antz
    Antz avatar
    5 posts
    Member since:
    Nov 2012

    Posted 16 Feb 2013 Link to this post

    Dear Ivan,

    Thank you very much.. very useful for me..
  11. monika
    monika avatar
    1 posts
    Member since:
    Mar 2015

    Posted 20 Mar 2015 in reply to Ivan Todorov Link to this post

    Hello sir,
    As i am adding tiles dynamically from database to groups like :-


    RadTileElement tile = new RadTileElement();
    tile.Text = "Testing";
    Group.Items.Add(tile);

    How can i get click event of the tile added in group.

    Thanks and regards
    monika
  12. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 25 Mar 2015 Link to this post

    Hello Monika,

    Thank you for writing.

    You can attach a click event handler to each tile added in a group. Please see my snippet below:
    public partial class Form1 : Form
    {
        private TileGroupElement group;
     
        public Form1()
        {
            InitializeComponent();
     
            this.group = new TileGroupElement();
            this.radPanorama1.Groups.Add(group);
            group.Text = "Group";
            this.radPanorama1.ShowGroups = true;
        }
     
        private void radButton1_Click(object sender, EventArgs e)
        {
            RadTileElement tile = new RadTileElement();
            tile.Text = "Testing";
            this.group.Items.Add(tile);
     
            tile.Click += tile_Click;
        }
     
        private void tile_Click(object sender, EventArgs e)
        {
            RadTileElement tile = (RadTileElement)sender;
            RadMessageBox.Show(tile.Text + " was clicked");
        }
    }

    I am also sending you a gif file of the result on my end.

    I hope this helps. Should you have further questions please do not hesitate to write back.


    Regards,
    Hristo Merdjanov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  13. Muhammad
    Muhammad avatar
    4 posts
    Member since:
    Mar 2014

    Posted 22 Feb in reply to Hristo Merdjanov Link to this post

    Hi Hristo Merdjanov,

    Thank you for replu all question.I have two questions

    1.  I am using radPanorama which has many tiles and i am giving functionality to user customize his application desktop (Dashboard). when user increase the size of radTile by using trackbar. The tile is overlaping to next tile. have you any suggestion to rearrange all tiles?

    2. when user right click on RadTile the click event is fired. have any property to prevent the fire click event on right click ?

  14. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 22 Feb Link to this post

    Hello Muhammad,

    Thank you for writing.

    The position of the tiles is defined using their Row and Column properties. A tile can also have a ColSpan and RowSpan determining how many cells it would take. Please check this documentation article: Settings and this forum post discussing a similar topic: Tile reposition and resizing.

    As to your second question, you can cast the arguments of the click handler to MouseEventArgs and check for the pressed mouse button: 
    private void tile_Click(object sender, EventArgs e)
    {
        if (((MouseEventArgs)e).Button == System.Windows.Forms.MouseButtons.Left)
        {
            RadTileElement tile = (RadTileElement)sender;
            RadMessageBox.Show(tile.Text + " was clicked");
        }
    }

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  15. Muhammad
    Muhammad avatar
    4 posts
    Member since:
    Mar 2014

    Posted 25 Feb in reply to Hristo Merdjanov Link to this post

    Hi Hristo Merdjanov,

     

    thank you for reply

    i am managing the Row,Column ,RowSpan and ColSpan. But if i am increase the size of selected tile from track bar the next tile still his postion so increases tile overlap to next tile.

    Right click solution is fine.

    I have another issue if i click on radPanorama and move the mouse scroll radPanoram increase the size like zooming. So Guide me

    thanks

    Regards,

    M.Amin

  16. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 25 Feb Link to this post

    Hi Muhammad,

    Thank you for writing.

    I am afraid I do not completely understand your scenario. Could you please open up a support ticket and send us your project so that we can investigate it locally. Please also refer this forum thread in your ticket.

    Looking forward to your reply.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  17. Muhammad
    Muhammad avatar
    4 posts
    Member since:
    Mar 2014

    Posted 06 Apr Link to this post

    Hi Ivan Todorov,

    Problem: Does not able to Drag radTileElement to left or right using touch screen

    Description:

         When ever I have to move an radTileElement using touch screen .I have to either move my finger to 

    release the radTileElement so I can move it in any direction where I want. When I grab an radTileElement 
    and move left or right it stays locked in its position.

    Can you give me any solution for drag radTileElement to left or right. 

    Regards,

    M.Amin

  18. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 08 Apr Link to this post

    Hi M.Amin,

    I tested our demo application on tablet and it worked fine. Please note that you would need to press and hold your finger on a tile element in order to unlock it and be able to move it back and forth.

    In case you keep experiencing issues. Please open up a support ticket and send us your project.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready