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

SfDataGrid and BindingSource

Is it possible to use a BindingSource component as a DataSource for a SFDataGrid? I have tried doing this in my project but the grid remains empty.

8 Replies

AA Arulraj A Syncfusion Team March 25, 2019 11:45 AM UTC

Hi Barry, 

Thanks for using Syncfusion product. 

We have analyzed your query to bind BindingSource as data source for SfDataGrid and we have provided support to bind BindingSource component as data source for SfDataGrid from the version 16.4.0.40. Could you please upgrade your version to 16.4.0.40 or above? 

You can find details about the BindingSource support in the following release notes link 
Link:  

Also please find sample for the same from the below link 
Sample Link: 
 
Please let us know, if you need any further  assistance on this. 

Arulraj A 



BA Barry March 26, 2019 10:35 AM UTC

I tried installing the updated the version and now Visual Studio won't start at all with the message "The setup for this installation of Visual Studio is not complete".


BA Barry March 26, 2019 08:37 PM UTC

I have just uninstalled VS and Syncfusion and reinstalled everything from scratch and all is working again now.


JP Jagadeesan Pichaimuthu Syncfusion Team March 27, 2019 05:53 AM UTC

Hi Barry, 

Thank you 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. 

Regards, 
Jagadeesan


BA Barry March 28, 2019 08:49 PM UTC

OK, I now have the sfDataGrid populated with data using a BindingSource. When I double click on any row I would like to open a window to edit that record. When I do however it always opens the first record in the dataset, not the one I have selected.



JP Jagadeesan Pichaimuthu Syncfusion Team March 29, 2019 06:42 AM UTC

Hi Barry, 

Thanks for your update. 

You can edit the record by using the e.DataRow.RowData on the CellDoubleClick event. Refer to the following code snippet and sample. 

Code snippet:  
sfDataGrid.CellDoubleClick += SfDataGrid_CellDoubleClick; 
private void SfDataGrid_CellDoubleClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e) 
{ 
    var rowData = e.DataRow.RowData as OrderInfo; 
    if (e.DataRow.RowIndex > 0 && rowData != null) 
    { 
        var inlineForm = new InlineForm(rowData); 
        inlineForm.StartPosition = FormStartPosition.CenterParent; 
        inlineForm.ShowDialog(); 
        e.DataRow.RowData = inlineForm.RowData; 
    } 
} 
 
Sample: 

Let us know whether this helps also if you need any further assistance on this. 
 
Regards, 
Jagadeesan


BA Barry March 29, 2019 08:29 AM UTC

Sorry, but I am really struggling with this. Why is the process so different to how it is done with a  DataGridView?  


JP Jagadeesan Pichaimuthu Syncfusion Team April 1, 2019 11:56 AM UTC

Hi Barry, 

Thanks for your update. 

In our last update we have provided the custom sample to achieve your requirement. You cannot directly assign a cell value to the record as like the datagridview (ex: grid.Row[index].Column[“Name”].Value = “Edited”). Since the SfDataGrid supports the data operations like sorting, grouping and filtering. We cannot directly access the cell values using the indexer like in DataGridView.  
If you want to directly edit the value on the cell double click event. You can use the following code snippet, 

Code Snippet: 
private void SfDataGrid_CellDoubleClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e) 
{ 
    if (e.DataRow.RowIndex > 0 && e.DataRow.RowData != null) 
    {         
        var propertiesProvider = this.sfDataGrid.View.GetPropertyAccessProvider(); 
 
        //To get the value from the selected record. 
        var customerID = propertiesProvider.GetValue(e.DataRow.RowData, "CustomerID"); 
 
        //To set the value to the particular field. 
        propertiesProvider.SetValue(e.DataRow.RowData, "CustomerID", "Edited"); 
    } 
} 
 
Sample: 
 
Let us know whether this helps also if you need any further assistance on this. 
 
Regards, 
Jagadeesan 


Loader.
Live Chat Icon For mobile
Up arrow icon