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

We want to add an employee entry to the top of the SfDataGrid in winforms.

Thread ID:





145850 Jul 10,2019 04:53 PM UTC Aug 2,2019 07:24 AM UTC WinForms 5
Tags: SfDataGrid
Smart law developer
Asked On July 10, 2019 04:53 PM UTC

Sample path : Syncfusion\Windows\\DataGrid.WinForms\Samples\Getting Started

We want to add an employee entry to the top of the SfDataGrid.
I want to add an employee entry programmatically at the top without using a data source.
Wpf examples can be found, but winforms examples are hard to find.
I would like some sample code.
thank you.

Farjana Parveen Ayubb [Syncfusion]
Replied On July 11, 2019 09:46 AM UTC

Hi Smart, 
Thank you for using Syncfusion controls. 
We can able to add the records programmatically at top of the SfDataGrid by using SfDataGrid.View.Records, please refer the below code example 
private void button1_Click(object sender, EventArgs e) 
    var record = sfDataGrid.View.CreateRecordEntry(new Employee(false, "Tamer", "Manager", "tamer@il.com", "US", "Perfect", 4, "High", 2000, 20000, "1029 - 12th Ave. S.", "Male")); 
    sfDataGrid.View.Records.Insert(0, record); 
Farjana Parveen A  

Smart law developer
Replied On July 11, 2019 05:36 PM UTC

Thank you for answer. If you run your example, there is a problem.

The problem is that when you click on the column head to reorder it, all the records you added will be lost.

Dinesh Babu Yadav [Syncfusion]
Replied On July 12, 2019 11:53 AM UTC

Hi Smart, 
We regret for the inconvenience caused. 
We have analyzed your query to add new row programmatically without using data source. We suspect that you do not want to insert rows into the underlying collection and this requirement can be achieved by adding unbound rows. Please refer to the below UG links to know more details on Unbound rows  
UG Link: 
Can you please confirm whether you are adding rows programmatically in WPF SfDataGrid as mentioned in the below forum?  
Forum Link: 
If yes, in that forum, we have suggested to use SfCellGrid and the requirement to add new rows programmatically without using underlying collection can be achieved only through Unbound rows for WPF SfDataGrid also. 
Also if we misunderstood your requirement, please let us know with more details. 
Dinesh Babu Yadav. 

Smart law developer
Replied On August 2, 2019 07:12 AM UTC

I saw it late. Thank you

Farjana Parveen Ayubb [Syncfusion]
Replied On August 2, 2019 07:24 AM UTC

Hi Smart, 
Thanks for the update. 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
Farjana Parveen A 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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
Live Chat Icon