Enable Column Reordering

3 posts, 1 answers
  1. Ahmet Özgür
    Ahmet Özgür avatar
    37 posts
    Member since:
    Jul 2009

    Posted 05 Apr 2012 Link to this post


    Hello,
    When i tick "enable column reordering" from specific task it works fine. but i want to enable this from code. i tried the followings but did not work.
    this.AllowColumnReorder = true;
    
    this.MasterTemplate.AllowColumnReorder = true;
    
    foreach (GridViewColumn item in this.MasterTemplate.Columns)
    {
           item.AllowSort=true;
           item.AllowReorder = true;
           item.IsPinned = false;               
    }
    Can u help about this.
    
     
  2. Answer
    Nikolay
    Admin
    Nikolay avatar
    1805 posts

    Posted 05 Apr 2012 Link to this post

    Hi Ahmet,

    Thank you for writing.

    Please note that when you set the "Enable Column Reordering" to false at design-time, a false value is serialized in the designer for the AllowColumnReorder property. So, even if you set the AllowColumnReoder to true in the constructor of your extended RadGridView class, your true value will be overridden by the false value serialized in the designer. Your only option to override what is serialized in the designer is to override the EndInit method in your extended RadGridView class:

    public class MyGrid : RadGridView
    {
        public override void EndInit()
        {
            base.EndInit();
     
            this.AllowColumnReorder = true;
        }
    }

    I hope this helps. All the best,
    Nikolay
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. Ahmet Özgür
    Ahmet Özgür avatar
    37 posts
    Member since:
    Jul 2009

    Posted 05 Apr 2012 Link to this post

    Thank you. It worked.
Back to Top