
Lorenzo Sforzini
Top achievements
Rank 1
Lorenzo Sforzini
asked on 18 Mar 2011, 02:43 PM
I have a hierarchic GridView and I want to scroll to the selected row after a new databind of the control.
If I do
this.radGridView1.TableElement.ScrollToRow(this.radGridView1.CurrentRow);
no problem if the current row is a parent row but if the current row is a child row the GridView scroll to the end.
How to scroll to a selected child row?
Thanks
4 Answers, 1 is accepted
0

Emanuel Varga
Top achievements
Rank 1
answered on 19 Mar 2011, 10:51 AM
Hello Lorenzo,
You could try parsing the Rows collection of the grid view or the Template's Row collection if you just want child rows, and when you reach your desired row you could just call EnsureVisible() on that row.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
You could try parsing the Rows collection of the grid view or the Template's Row collection if you just want child rows, and when you reach your desired row you could just call EnsureVisible() on that row.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0

Lorenzo Sforzini
Top achievements
Rank 1
answered on 21 Mar 2011, 09:23 AM
Thank you. That solves my problem
0

Lorenzo Sforzini
Top achievements
Rank 1
answered on 16 Jun 2011, 08:51 AM
Even about scroll. I have this code refreshing the GridView:
When I ribind the GridView the selected row is no longer in the datasource because its state change and the rows are filtered. At the end of the function, my intention is that the current row is the following row than the original selected and the GridView scroll to ensure the new selected row is visible. If the orginal selected row is a child row, the following row is selected but the GridView doesn't scroll to ensure that is visible. I have WinControl version 2010.3.10.1215.
What I can do?
Thanks
List<
int
> selectedRowsIndexes = new List<
int
>();
List<
int
> selectedRowsIndexesTemplate = new List<
int
>();
this.radGridView1.BeginEdit();
foreach (GridViewDataRowInfo row in this.radGridView1.SelectedRows)
{
if (this.radGridView1.Rows.IndexOf(row) == -1)
{
selectedRowsIndexesTemplate.Add(this.radGridView1.Templates[0].Rows.IndexOf(row));
}
else
{
selectedRowsIndexes.Add(this.radGridView1.Rows.IndexOf(row));
}
}
this.radGridView1.DataSource = lstMaster;
this.radGridView1.Templates[0].DataSource = lstDetail;
foreach (var item in this.radGridView1.ChildRows)
{
if (item.ChildRows.Count > 0)
{
item.IsExpanded = true;
}
}
foreach (int index in selectedRowsIndexes)
{
if (this.radGridView1.Rows.Count > index)
{
this.radGridView1.Rows[index].IsSelected = true;
this.radGridView1.Rows[index].IsCurrent = true;
this.radGridView1.Rows[index].EnsureVisible();
}
else if (this.radGridView1.Rows.Count > 0)
{
this.radGridView1.Rows[0].IsSelected = true;
this.radGridView1.Rows[0].IsCurrent = true;
this.radGridView1.Rows[0].EnsureVisible();
}
}
foreach (int index in selectedRowsIndexesTemplate)
{
if (this.radGridView1.Templates[0].Rows.Count > index)
{
this.radGridView1.Templates[0].Rows[index].IsSelected = true;
this.radGridView1.Templates[0].Rows[index].IsCurrent = true;
this.radGridView1.Templates[0].Rows[index].EnsureVisible();
}
else if (this.radGridView1.Templates[0].Rows.Count > 0)
{
this.radGridView1.Templates[0].Rows[0].IsSelected = true;
this.radGridView1.Templates[0].Rows[0].IsCurrent = true;
this.radGridView1.Templates[0].Rows[0].EnsureVisible();
}
else if (this.radGridView1.Rows.Count > 0)
{
this.radGridView1.Rows[0].IsSelected = true;
this.radGridView1.Rows[0].IsCurrent = true;
this.radGridView1.Rows[0].EnsureVisible();
}
}
this.radGridView1.CurrentRow.EnsureVisible();
this.radGridView1.TableElement.EnsureRowVisible(this.radGridView1.CurrentRow);
this.radGridView1.EndEdit();
When I ribind the GridView the selected row is no longer in the datasource because its state change and the rows are filtered. At the end of the function, my intention is that the current row is the following row than the original selected and the GridView scroll to ensure the new selected row is visible. If the orginal selected row is a child row, the following row is selected but the GridView doesn't scroll to ensure that is visible. I have WinControl version 2010.3.10.1215.
What I can do?
Thanks
0
Hi Lorenzo Sforzini,
Thank you for writing.
Have you tried your scenario with the latest release Q1 2011 SP1 (2011.1.11.419) ? It contains many fixes and numerous improvements. It is possible that described case could work properly.
Let me know whether the latest version helped.
Regards,
Martin Vasilev
the Telerik team
Thank you for writing.
Have you tried your scenario with the latest release Q1 2011 SP1 (2011.1.11.419) ? It contains many fixes and numerous improvements. It is possible that described case could work properly.
Let me know whether the latest version helped.
Regards,
Martin Vasilev
the Telerik team