How do I keep the focus at the bottom of a datagrid by default whenever new rows are added to the datagrid?
I'm simply trying to keep the focus at the bottom of the datagrid by default and especially when new rows are added. This is what I'm currently seeing now: https://prnt.sc/mcZGCqRbq0zg
I don't know if my application is AddNewRowSupport enabled or not
When a new row is added to the SF datagrid he want the scrollbar at the bottom . So this way the user don't need to scroll down to see new rows added
// using a standard datagrid we are able to set the scrollbar to the bottom
dataGridViewInfo.FirstDisplayedScrollingRowIndex = dataGridViewInfo.RowCount - 1;
|
sfDataGrid1.View.Records.CollectionChanged += OnCollectionChanged;
private void OnCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
//here scroll to a last record programmatically while new row added in SfDatGrid
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
{
this.sfDataGrid1.BeginInvoke(new Action(() =>
{
//here get the last rowindex of SfDataGrid
var lastRowIndex = this.sfDataGrid1.TableControl.ResolveToRowIndex(sfDataGrid1.View.Records.Count);
//scroll to a last record in DataGrid using the SfDataGrid.TableControl.ScrollRows.ScrollInView
this.sfDataGrid1.TableControl.ScrollRows.ScrollInView(lastRowIndex);
this.sfDataGrid1.TableControl.UpdateScrollBars();
}));
}
} |
Yes this is exactly what I mean. I was trying to explain it several times but not well enough I guess that when a new item is added to the datarow the focus stays at the items at the top of the datagrid but I want to keep the focus at the bottom of the datagrid instead. I also know how to do it with a normal datagrid but trying to ask syncfusion how to do it with their datagrid
ALL IN