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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Add Row from SerialPort Incoming Data into SfDatagrid

Thread ID:

Created:

Updated:

Platform:

Replies:

149605 Dec 3,2019 05:07 AM UTC Dec 4,2019 12:46 PM UTC WPF 3
loading
Tags: SfDataGrid
Carlos Branty
Asked On December 3, 2019 05:25 AM UTC



I was able to successfully make the connection with serialport, and I receive the data without any problems, this data changes every second I want to take Every data that arrives, to a new Culumn and row of SFDatagrid.

Mohanram Anbukkarasu [Syncfusion]
Replied On December 3, 2019 07:25 AM UTC

Hi Carlos, 

Thanks for contacting Syncfusion support. 

In SfDataGrid, the SfDataGrid.View.Records.CollectionChanged event will raise whenever any new record is added or removed from the underlying datasource and the SfDataGrid.View.RecordPropertyChanged event will raise when any existing data is changed. You can use these events to achieve your requirement as shown in the following code example.  

Code example :  

this.dataGrid.Loaded += OnDataGrid_Loaded; 
 
private void OnDataGrid_Loaded(object sender, RoutedEventArgs e) 
{ 
    this.dataGrid.View.Records.CollectionChanged += OnRecords_CollectionChanged; 
    this.dataGrid.View.RecordPropertyChanged += OnView_RecordPropertyChanged; 
} 
 
private void OnView_RecordPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) 
{ 
    // Do you customization here. 
} 
 
private void OnRecords_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) 
{ 
    if(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) 
    { 
        // Do you customization here. 
    } 
} 

Please let us know if you require further assistance from us.  

Regards, 
Mohanram A. 


Carlos Branty
Replied On December 4, 2019 12:40 AM UTC

Hi Carlos, 

Thanks for contacting Syncfusion support. 

In SfDataGrid, the SfDataGrid.View.Records.CollectionChanged event will raise whenever any new record is added or removed from the underlying datasource and the SfDataGrid.View.RecordPropertyChanged event will raise when any existing data is changed. You can use these events to achieve your requirement as shown in the following code example.  

Code example :  

this.dataGrid.Loaded += OnDataGrid_Loaded; 
 
private void OnDataGrid_Loaded(object sender, RoutedEventArgs e) 
{ 
    this.dataGrid.View.Records.CollectionChanged += OnRecords_CollectionChanged; 
    this.dataGrid.View.RecordPropertyChanged += OnView_RecordPropertyChanged; 
} 
 
private void OnView_RecordPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) 
{ 
    // Do you customization here. 
} 
 
private void OnRecords_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) 
{ 
    if(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) 
    { 
        // Do you customization here. 
    } 
} 

Please let us know if you require further assistance from us.  

Regards, 
Mohanram A. 


Thanks for the support Mr.Mohanram A. I tried to attach the arduino data via serialport in SFDtagrid but I get an error "reference to object not set as
  instance of an object "I have attached the code I made would greatly appreciate your help, Thank you

Attachment: SrialPortToSFDataGrid_aa7932c3.zip

Mohanram Anbukkarasu [Syncfusion]
Replied On December 4, 2019 12:46 PM UTC

Hi Carlos, 

Thanks for the update.  

We have checked the provided sample and the exception occurred in it. The null reference exception doesn’t arrive from the SfDataGrid. It occurs in the creation of the data using the SerialPort. Kindly check the creation of data from serial port to resolve the exception.  

Please let us know if your require any other assistance from us.  

Regards, 
Mohanram A. 


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

Live Chat Icon For mobile
Live Chat Icon