how to set the currentcell

I am working in vs2017 visualbasic winform.  I added a syncfusion datagrid to my form and load the data - sfdatagrid.DataSource = tmpUIDatatable

Each time I refresh with a new tmpUIDatatable, the scroll bars stay where they were.  I need to bring the focus back to the top-left.
I see there is a method 

CurrentCell

Gets or sets the currently active cell.


When I try sfdatagrid.CurrentCell.MoveTo(1,0), intellisense says "MoveTo is not a member of CurrentCellManager".



1 Reply 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team March 26, 2021 02:59 PM UTC

Hi Karla Franke,

Thank you for contacting Syncfusion Support.

You can move the current cell by using the MoveToCurrentCell method in SfDataGrid.
Please refer the below code snippet, 
private void button1_Click(object sender, EventArgs e) 
{            
            this.sfDataGrid1.DataSource = new OrderInfoCollection().OrdersListDetails.Where(x => x.CustomerID != "FRANS"); 
            //Move the Scroll bar to top of DataGrid  
            this.sfDataGrid1.MoveToCurrentCell(new RowColumnIndex(1, 0)); 
} 
In another way you can scroll the scrollbar by using ScrollInView method in SfDataGrid. Please refer the below code snippet, 
private void button1_Click(object sender, EventArgs e) 
{            
            this.sfDataGrid1.DataSource = new OrderInfoCollection().OrdersListDetails.Where(x => x.CustomerID != "FRANS");            
 
            //Move the Scroll bar to top of DataGrid 
            this.sfDataGrid1.TableControl.ScrollRows.ScrollInView(1); 
            this.sfDataGrid1.TableControl.UpdateScrollBars(); 
            this.sfDataGrid1.TableControl.Invalidate(); 
} 
Please let us know, if you require further assistance on this.

Regards,
Vijayarasan S
 



Marked as answer
Loader.
Up arrow icon