Show columns in specific order by default

2 posts, 0 answers
  1. Patrick
    Patrick avatar
    42 posts
    Member since:
    Jul 2012

    Posted 05 Jun 2013 Link to this post

    I'm trying to figure out the easiest way to have my columns start in a default order(left to right) for all users.  I tried setting them in the IList<T> that I use to populate the DataSource but that doesn't work.  

    Do I have any options besides setting each column manually following the instructions on this page -->Reordering Columns

    That would be VERY cumbersome...

    Additionally, I notice that Intellisense labels
    as "[deprecated]" so what is the alternative?

  2. Stefan
    Stefan avatar
    2891 posts

    Posted 10 Jun 2013 Link to this post

    Hi Patrick,

    Thank you for writing.

    The grid will read your objects fields in the way they are defined and based on this way will produce its columns. For example:
    public partial class Form1 : Form
        public Form1()
            List<MyObject> l = new List<MyObject>();
            l.Add(new MyObject() { FirstColumn = 1, SecondColumn = "2" });
            radGridView1.DataSource = l;
    class MyObject
        public string SecondColumn { get; set; }
        public int FirstColumn { get; set; }

    this would produce a grid where the SecondColumn will be first and the FirstColumn will be second, while using the following object will do the opposite:
    class MyObject
        public int FirstColumn { get; set; }
        public string SecondColumn { get; set; }

    As to the obsolete Move method, there is another Move method with different signature that should be used instead:
    [Obsolete("This method is obsolete and will be removed for the next release. Please use Move(int oldIndex, int newIndex) instead.")]

    I hope this helps.
    RadChart for WinForms is obsolete. Now what?
  3. DevCraft banner
Back to Top