Grid horizontally autoscroll on row changed

4 posts, 1 answers
  1. Elek
    Elek avatar
    3 posts
    Member since:
    Nov 2011

    Posted 19 Apr 2012 Link to this post

    Hello,

    I have Winform RadGridView and when I click in a cell that is partially displayed the grid horizontally auto scrolls to right, than by the next click scrolls to left etc.

     

    This is not to very userfriendly.  See Telerik demo in Attach

     

    How can I horizontally auto scrolling fix

    Regards,
    Elek

  2. Answer
    Jack
    Admin
    Jack avatar
    2333 posts

    Posted 21 Apr 2012 Link to this post

    Hello Elek,

    This issue may occur when the column width is larger than the visible area. In this case RadGridView tries to ensure that the current cell is fully visible and it fails. I logged the issue in our issue tracking system and it will be addressed in one of our upcoming releases. I updated your Telerik points for reporting this issue.

    You can work around this case by overriding the default EnsureCellVisible method in GridTableElement. Consider the code below:
    public class CustomTableView : TableViewDefinition
    {
        public override IRowView CreateViewUIElement(GridViewInfo viewInfo)
        {
            return new CustomTableElement();
        }
    }
     
    public class CustomTableElement : GridTableElement
    {
        protected override Type ThemeEffectiveType
        {
            get
            {
                return typeof(GridTableElement);
            }
        }
     
        public override bool EnsureCellVisible(GridViewRowInfo rowInfo, GridViewColumn column)
        {
            GridCellElement cell = GetCellElement(rowInfo, column);
            if (cell != null)
            {
                GridVirtualizedRowElement row = cell.RowElement as GridVirtualizedRowElement;
                if (row != null && cell.ColumnInfo.Width > row.ScrollableColumns.Size.Width)
                {
                    return true;
                }
            }
     
            return base.EnsureCellVisible(rowInfo, column);
        }
    }

    Use the following code to replace the default view definition:
    this.radGridView1.ViewDefinition = new CustomTableView();

    I hope this helps.
     
    Kind regards,
    Jack
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. Elek
    Elek avatar
    3 posts
    Member since:
    Nov 2011

    Posted 22 Apr 2012 Link to this post

    Hello Jack!

    Thanks for your solution, that works!

    Kind regards Elek
  4. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 23 Apr 2012 Link to this post

    Hi Elek,

    I am glad that I could help. Should you have any other questions, do not hesitate to contact us.
     
    Kind regards,
    Jack
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top