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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfDataGrid and BindingSource

Thread ID:

Created:

Updated:

Platform:

Replies:

143507 Mar 23,2019 10:14 PM UTC Apr 1,2019 11:56 AM UTC WinForms 8
loading
Tags: SfDataGrid
Barry
Asked On March 23, 2019 10:14 PM UTC

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.

Arulraj A [Syncfusion]
Replied On 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 


Barry
Replied On 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".

Barry
Replied On 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.

Jagadeesan Pichaimuthu [Syncfusion]
Replied On 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

Barry
Replied On 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.


Jagadeesan Pichaimuthu [Syncfusion]
Replied On 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

Barry
Replied On 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?  

Jagadeesan Pichaimuthu [Syncfusion]
Replied On 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 


CONFIRMATION

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

;