Completed
Last Updated: 05 Nov 2014 14:33 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 02 Jul 2014 07:11
Category: GridView
Type: Bug Report
0
FIX. RadGridView - Horizontal scroll bar changes its position unexpectedly while filtering
To reproduce:
1.Add a RadGridView and add twelve columns at design time.
2.Enable filtering and use the following code:

public Form1()
{
    InitializeComponent();
    radGridView1.MasterTemplate.MultiSelect = true;
}
private void Form1_Load(object sender, EventArgs e)
{
    foreach (var column in radGridView1.Columns)
    {
        column.Width = 100;
    }
}
3.When you run the application, click over the filtering cell for the 3rd column. Type in some text and click the filter button. As a result the horizontal scroll bar is positioned at right most.

Workaround:
radGridView1.MouseDown += radGridView1_MouseDown;
radGridView1.TableElement.HScrollBar.ValueChanged += HScrollBar_ValueChanged;

int scrollBarValue = 0;
bool shouldResetValue = false;

private void radGridView1_MouseDown(object sender, MouseEventArgs e)
{
    RadElement clickecElement = this.radGridView1.ElementTree.GetElementAtPoint(e.Location);
    GridFilterRowElement filterRowElement = clickecElement.FindAncestor<GridFilterRowElement>();
    GridNewRowElement newRowElement = clickecElement.FindAncestor<GridNewRowElement>();
    if (clickecElement is GridFilterRowElement || clickecElement is GridNewRowElement ||
        filterRowElement != null || newRowElement != null)
    {
        shouldResetValue = true;
    }
    else
    {
        shouldResetValue = false;
    }
    scrollBarValue = this.radGridView1.TableElement.HScrollBar.Value;
}

private void HScrollBar_ValueChanged(object sender, EventArgs e)
{
    if (shouldResetValue)
    {
        this.radGridView1.TableElement.HScrollBar.Value = scrollBarValue;
    }
}

0 comments