This is a migrated thread and some comments may be shown as answers.

Grid horizontally autoscroll on row changed

3 Answers 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Elek
Top achievements
Rank 1
Elek asked on 19 Apr 2012, 09:01 PM

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

3 Answers, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 21 Apr 2012, 02:33 PM
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 >>
0
Elek
Top achievements
Rank 1
answered on 22 Apr 2012, 10:34 AM
Hello Jack!

Thanks for your solution, that works!

Kind regards Elek
0
Jack
Telerik team
answered on 23 Apr 2012, 03:18 PM
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 >>
Tags
GridView
Asked by
Elek
Top achievements
Rank 1
Answers by
Jack
Telerik team
Elek
Top achievements
Rank 1
Share this question
or