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 do I map column of sfDataGrid to datasource (BindingSource) in design time?

Thread ID:





146748 Aug 17,2019 08:44 AM UTC Aug 19,2019 03:21 PM UTC WinForms 1
Tags: SfDataGrid
Asked On August 17, 2019 11:13 AM UTC

public class myData : IEditableobject
        public string name { get; set; }
        public Int32 age {get;set;}
        public string value { get; set; }


-- Design time
1. I have created myBindingSource for MyData and linked it to DataSource of sfDataGrid.
2. I created columns of sfDataGrid and set MappingName to property name of MyData.
3. I added some code.

        List arr = new List(); 
             private void Form1_Load(object sender, EventArgs e)
          //add sample data
            arr.Add(   new myData(){ name = "Hell2o", age = 32, value = "hasdjasd" });
            arr.Add(  new myData(){ name = "Hello3", age = 12, value = "hasdjasd" }  );
            arr.Add(new myData() { name = "Hello4", age = 13, value = "hasdjasd" });

            myDataBindingSource.DataSource = arr;

myDataBindingSource is connected to DataGridView control too.

When I run the project, sfDataGrid does not show any data but DataGridView shows all data.

I know I can do it with code but I don't want to add code for visual property setting.
I'd like to finish visual design in ide as possible as I can.

I tried  GridGroupingControl but it does not have RowValidation event.

Susmitha Sundar [Syncfusion]
Replied On August 19, 2019 03:21 PM UTC

Thank you for using Syncfusion controls. 
We could able to reproduce your reported query” SfDataGrid datasource not updated when set the bindingsource at Form_Load event”. We recommed to set the SfDataGrid datasource in Form_Load event. Please refer the following code snippet, 
BindingSource bindingSource; 
public Form1() 
     bindingSource = new BindingSource(); 
    this.Load += Form1_Load; 
List<OrderInfo> list = new List<OrderInfo>(); 
private void Form1_Load(object sender, EventArgs e) 
     list.Add(new OrderInfo(1001, "Maria Anders", "Germany", "ALFKI", "Berlin")); 
     list.Add(new OrderInfo(1002, "Ana Trujilo", "Mexico", "ANATR", "Mexico D.F.")); 
     list.Add(new OrderInfo(1003, "Antonio Moreno", "Mexico", "ANTON", "Mexico D.F.")); 
     list.Add(new OrderInfo(1004, "Thomas Hardy", "UK", "AROUT", "London")); 
     list.Add(new OrderInfo(1005, "Christina Berglund", "Sweden", "BERGS", "Lula")); 
     bindingSource.DataSource = list; 
     this.sfDataGrid1.DataSource = bindingSource; 
GridGroupingControl does not provide support for Rowvalidation event. SfDataGrid provide this support. Please refer following user guide documentation, 
Please contact us for further assistance. 
Susmitha S 


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