We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add and delete rows and columns in runtime?

Platform: Xamarin.Forms |
Control: SfDataGrid |
Published Date: November 18, 2015 |
Last Revised Date: December 15, 2016
Tags: crud

SfDataGrid allows you to add or delete rows and columns from the ItemsSource in run time. When you set the ItemsSource of the grid with a collection that implements the ICollectionChanged interface then the SfDataGrid automatically refreshes the view against the CRUD operations.

Refer the below code example in which the SfDataGrid is set with an ObservableCollection as ItemsSource. The ObservableCollection implements the INotifyCollectionChanged interface and hence will result in automatic refreshing of view when adding or removing rows or columns in runtime.

Refer the following code example to add or remove rows and columns in SfDataGrid at runtime.


When the ItemsSource of the grid is set with a collection that does not implement the interface ICollectionChanged interface, then the grid has to be manually refreshed for runtime changes.

The following screenshots shows the final outcome upon execution of the above code



A working sample for this KB is available in the below link


2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment
Jan 24, 2019


Using the above sample, i able to add new columns and rows dynamically to the datagrid. But i am unable to get the cell values values of new columns added. Can you help me with this one asap.

Sivaraman Sivagurunathan [Syncfusion]
Jan 27, 2019

Hi Arshdeep,


We have checked your query. you can achieved your requirement by SfDataGrid.View.Records.CollectionChanged and SfDataGrid.Columns.CollectionChanged event. We have pared the sample based on your requirement and attached for your reference you can download the same from the following link and code snippet.



dataGrid.View.Records.CollectionChanged += Records_CollectionChanged;


private void Records_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)


    var recordIndex = this.dataGrid.ResolveToRowIndex(e.NewItems[0]);

    var rowIndex = this.dataGrid.ResolveToRowIndex(recordIndex);

    var data = this.dataGrid.GetRecordAtRowIndex(rowIndex);




Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGridDemo-1364539700




Mar 23, 2020

Hello, where does the "Info" in line 14 comes from?


Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile