How can i control add new row event is finished

I need to add a new row to the database, Need to know is event finished just like CurrentCellEndEdit event.

After the set new rows all values set it should be triggered and add new values to database 

Please explain with some sample code.

Thanks


7 Replies

MA Mohanram Anbukkarasu Syncfusion Team May 23, 2018 07:08 AM UTC

Hi Eren,  
 
Thanks for contacting Syncfusion support. 
 
When you are adding a new row using AddNewRow, you can able to listen the adding operation by using CollectionChanged event in SfDataGrid.View. 
 
Please refer the below code example and sample from the given location. 
 
Code Example 
 
public Form1() 
{ 
    InitializeComponent(); 
     
    sfDataGrid.DataSource = data.OrdersListDetails; 
 
    (sfDataGrid.View as CollectionViewAdv).CollectionChanged += CollectionChanged; 
} 
 
void CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) 
{ 
    if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) 
    { 
        // Do your needed customization here.  
    } 
} 
 
 
Regards, 
Mohanram A. 



ER Eren replied to Mohanram Anbukkarasu May 24, 2018 07:36 PM UTC

Hi Eren,  
 
Thanks for contacting Syncfusion support. 
 
When you are adding a new row using AddNewRow, you can able to listen the adding operation by using CollectionChanged event in SfDataGrid.View. 
 
Please refer the below code example and sample from the given location. 
 
Code Example 
 
public Form1() 
{ 
    InitializeComponent(); 
     
    sfDataGrid.DataSource = data.OrdersListDetails; 
 
    (sfDataGrid.View as CollectionViewAdv).CollectionChanged += CollectionChanged; 
} 
 
void CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) 
{ 
    if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) 
    { 
        // Do your needed customization here.  
    } 
} 
 
 
Regards, 
Mohanram A. 


Thanks it's work great but mdi child form event don't triggered (like KeyUp event) how can ı fix this problem?


MA Mohanram Anbukkarasu Syncfusion Team May 25, 2018 09:03 AM UTC

Hi Eren, 
 
Thanks for your update. 
 
We have checked your reported scenario, but we can’t able to reproduce it on our end. We have added the SfDataGrid into an MDI child form. The CollectionChanged event fires when we add a new row. 
 
Please refer the below sample which we are tried to reproduce the issue. 
 
 
If still you have faced the issue, please revert by modifying the attached sample based on your application along with the replication procedure, please share your application if it is possible. It will be helpful for us to analyze further.    
 
 
Regards, 
Mohanram A. 



ER Eren May 26, 2018 04:05 PM UTC

You misunderstood me CollectionChanged event fires but another event of mdichildform don't fires (KeyUp,KeyDown etc.)

Not SfDatagrid event or MdiParent event.I am trying to when Press F5 key datagrid's datasource updated or press DELETE selected row deleted

UserControl KeyPress Or Down Event not fired

And i can't set text (title) property of form 
Here 

public partial class CurrentList : frmList
    {
        public CurrentList(string _title, DataTable dtSource)
        {
            InitializeComponent();
            this.Text = _title;
            sfDataGrid2.DataSource = dtSource;

        }
    }




MA Mohanram Anbukkarasu Syncfusion Team May 28, 2018 12:07 PM UTC

Hi Eren, 
 
Thanks for your update. 
 
By default, Form will receive all the key events only when enabling the Form.KeyPreview property. You should enable the KeyPreview property of the MDI child form. 
 
Please refer the below MSDN link for further details. 
 
We have prepared a simple sample with MDI child based on your scenario. Please  refer the sample from the below location. 
 
 
Regards, 
Mohanram A. 



ER Eren May 28, 2018 07:12 PM UTC

thank you i solved the problem before


MA Mohanram Anbukkarasu Syncfusion Team May 29, 2018 04:15 AM UTC

Hi Eren,  
 
Thanks for your update. 
 
Please let us know if you have any other queries. 
 
Regards, 
Mohanram A. 


Loader.
Up arrow icon