Reverse list of recent files

7 posts, 0 answers
  1. Jean-Marc Windholz
    Jean-Marc Windholz avatar
    42 posts
    Member since:
    Sep 2009

    Posted 13 Oct 2010 Link to this post

    Hi, 
    I'm using the StartMenuRightColumnItems collection for the Recent files list in a c# project  and 
    I would reverse the order of the list, thus the last opened file is showed at the top of the list 
    and not al the bottom.

    regards
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 13 Oct 2010 Link to this post

    Hello Jean-Marc,

    If i understood correctly, and you just want to reverse the items in a DataSource, you can just use Linq and use Reverse().

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jean-Marc Windholz
    Jean-Marc Windholz avatar
    42 posts
    Member since:
    Sep 2009

    Posted 13 Oct 2010 Link to this post

    Hello Emanuel,
    I saw Reverse() but it doesn't make anything alone, and I don't know how I can
    use Linq with StartMenuRightColumnItems 

    Best regards
  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 13 Oct 2010 Link to this post

    Hi, 

    Does this help? 
    Form1_Load(System.Object sender, System.EventArgs e)
    {
        Telerik.WinControls.RadItemOwnerCollection s = default(Telerik.WinControls.RadItemOwnerCollection);
        s = this.RadRibbonBar1.StartMenuRightColumnItems;
        Array items = s.ToArray();
        Array.Reverse(items);
        foreach (Telerik.WinControls.RadItem i in items) {
            MessageBox.Show(i.Text);
        }
    }

    Edit: Converted from the following VB method
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim s As Telerik.WinControls.RadItemOwnerCollection
        s = Me.RadRibbonBar1.StartMenuRightColumnItems
        Dim items As Array = s.ToArray()
        Array.Reverse(items)
        For Each i As Telerik.WinControls.RadItem In items
            MessageBox.Show(i.Text)
        Next
    End Sub


    Let me know if you need further help
    Richard
  6. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 13 Oct 2010 Link to this post

    Hello Jean-Marc,

    There must be an easier and better way of doing this, but this will do the trick:
    RadItem[] array = new RadItem[this.radRibbonBar1.StartMenuRightColumnItems.Count];
    this.radRibbonBar1.StartMenuRightColumnItems.CopyTo(array, 0);
    this.radRibbonBar1.StartMenuRightColumnItems.Clear();
    array = array.Reverse().ToArray<RadItem>();
    this.radRibbonBar1.StartMenuRightColumnItems.AddRange(array);

    Update... or this:
    var array = this.radRibbonBar1.StartMenuRightColumnItems.Reverse().ToArray();
    this.radRibbonBar1.StartMenuRightColumnItems.Clear();
    this.radRibbonBar1.StartMenuRightColumnItems.AddRange(array);

    Hope this helps, if you have any other questions or comments, please let me know,

    Offtopic: Sorry Richard for almost double posting, i really should remember refresh pages before posting...

    Best Regards,
    Emanuel Varga
  7. Jean-Marc Windholz
    Jean-Marc Windholz avatar
    42 posts
    Member since:
    Sep 2009

    Posted 13 Oct 2010 Link to this post

    thank you Emanuel and Richard,
    with your suggestions I solved all.
  8. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 13 Oct 2010 Link to this post

    Glad that you got it sorted. 

    //Off Topic
    @Emanuel - No problem about the double posting. It happens to me too. :o) - At least the question was answered
Back to Top
UI for WinForms is Visual Studio 2017 Ready