ADD NEW RECORD IN SEPARATE FORM

Dear Sir,

I have form with SFDATAGrid listing of forms records.

Is it possible to add record in SFDATAGRID with new form or update/edit current record in new form ?

And after add/edit the records, SFDATAGRID will not take more time for refresh.. We can say its live updates in SFDATAGRID also ?

Pls send me small sample for the same.

Thanks
Deepak

1 Reply

MA Mohanram Anbukkarasu Syncfusion Team September 13, 2018 10:23 AM UTC

 
Thanks for contacting Syncfusion support. 
 
It is possible to add/edit records in SfDataGrid with new form. You can achieve this by adding or editing the records in the underlying data source of the SfDataGrid. We have created a simple sample to achieve your requirement. Please refer to the following code example and sample from the given location. 
 
Code Example : 
 
this.sfDataGrid.CellDoubleClick += sfDataGrid_CellDoubleClick; 
 
void sfDataGrid_CellDoubleClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e) 
{ 
    e.Cancel = true; 
    orderInfo = new OrderInfo(); 
    form = new UpdateForm(); 
    orderInfo = e.DataRow.RowData as OrderInfo; 
    form.textBox1.Text = orderInfo.OrderID.ToString(); 
    form.textBox2.Text = orderInfo.CustomerID; 
    form.textBox3.Text = orderInfo.ProductName; 
    form.updateButton.Click += UpdateButton_Click; 
    form.addButton.Visible = false; 
    form.Show(); 
} 
 
private void UpdateButton_Click(object sender, System.EventArgs e) 
{ 
    if (orderInfo.OrderID.ToString() != form.textBox1.Text) 
        orderInfo.OrderID = int.Parse(form.textBox1.Text); 
    if (orderInfo.CustomerID != form.textBox2.Text) 
        orderInfo.CustomerID = form.textBox2.Text; 
    if (orderInfo.ProductName != form.textBox3.Text) 
        orderInfo.ProductName = form.textBox3.Text; 
    form.Close(); 
} 
 
void AddButton_Click(object sender, System.EventArgs e) 
{ 
    if (!(string.IsNullOrEmpty(form.textBox1.Text) || string.IsNullOrEmpty(form.textBox2.Text) || string.IsNullOrEmpty(form.textBox3.Text))) 
    { 
        data.OrdersListDetails.Add(new OrderInfo() { OrderID = int.Parse(form.textBox1.Text), CustomerID = form.textBox2.Text, ProductName = form.textBox3.Text }); 
        form.Close(); 
    } 
} 
 
 
 
Regards, 
Mohanram A. 


Loader.
Up arrow icon