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.
Unfortunately, activation email could not send to your email. Please try again.

delete a row in the record

Thread ID:

Created:

Updated:

Platform:

Replies:

96823 Oct 7,2010 03:33 PM Mar 30,2018 12:33 AM Windows Forms 5
loading
Tags: GridControl
harshini
Asked On October 7, 2010 03:33 PM

private void butDelete_Click(object sender,EventArgs e)
{
if (grdDisplayItems.Table.CurrentRecord != null)
{
if (grdDisplayItems.Table.Records.Count == 1)
{
grdDisplayItems.Table.Records[0].Delete();
}
else
{
this.grdDisplayItems.Table.CurrentRecord.Delete();
}
//this.grdDisplayItems.Table.Records[0].Delete();
}
}
The delete method deletes all records except for the record that iis left out.for e if we have 4 records it deletes 3 records succesfully but the last record is not deleted at all


if the grid has just one record then also the record is not getting deleted
I am getting an exception object refrence not set to an instanc eof an object

Stack trace:
StackTrace " at System.Data.DataView.GetRow(Int32 index)\r\n at System.Data.DataView.System.Collections.IList.RemoveAt(Int32 index)\r\n at Syncfusion.Grouping.Table.DeleteRecord(Record r)\r\n at Syncfusion.Grouping.Record.Delete()" string






Christopher Issac Sunder K [Syncfusion]
Replied On October 9, 2010 12:37 PM

Hi Harshini,

Thank you for your interest in Syncfusion products.

To delete the records one – by – one, you can check whether the record count is greater than zero. Here is the code snippets which explains the deletion in GridGroupingControl.


private void button1_Click(object sender, EventArgs e)
{
if (this.gridGroupingControl1.Table.CurrentRecord != null)
{
this.gridGroupingControl1.Table.CurrentRecord.Delete();
}
else
{
if (this.gridGroupingControl1.Table.Records.Count > 0) // check with this condition
this.gridGroupingControl1.Table.Records[0].Delete();
}
}


Please refer the following sample which illustrates the above.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GGC_Deletion-1675744949.zip

Please let me know if you have any other concerns.

Regards,
Christo.



harshini
Replied On October 13, 2010 10:46 AM

hi..

the problem here is when zeroth record is reached the table still has the value i.e

grdDisplayItems.Table.CurrentRecord != null condition is satisfied and
this.grdDisplayItems.Table.CurrentRecord.Delete(); is executed because of which whole application terminates and i get the exception.


Rajadurai C [Syncfusion]
Replied On October 14, 2010 04:09 PM

Hi Harshini,

Thanks for your update.

The CurrentRecord will not be null when the focus is in the AddNewRecord row. Hence, you could handle the following modified condition instead.

if (this.gridGroupingControl1.Table.CurrentRecord != null && this.gridGroupingControl1.Table.CurrentRecord != this.gridGroupingControl1.Table.AddNewRecord)
{
this.gridGroupingControl1.Table.CurrentRecord.Delete();
}


Please let us know if you have any further concerns.

Regards,
Rajadurai


juan
Replied On March 29, 2018 06:37 PM

hi..

the problem here is when zeroth record is reached the table still has the value i.e

grdDisplayItems.Table.CurrentRecord != null condition is satisfied and
this.grdDisplayItems.Table.CurrentRecord.Delete(); is executed because of which whole application terminates and i get the exception.


hola soy un nuevo usuario

Mohanraj Gunasekaran [Syncfusion]
Replied On March 30, 2018 12:33 AM

Hi juan, 
 
Thanks for using Syncfusion product. 
 
In order to delete the current record, you can also use the Records.Count property. Please refer to the below code example, 
 
Code example 
if (this.gridGroupingControl1.Table.CurrentRecord != null && this.gridGroupingControl1.Table.Records.Count > 0) 
{
    this.gridGroupingControl1.Table.CurrentRecord.Delete();
}
 
 
 
 
We have documented GridGroupingControl guide lines and it will be available in following UG link, 
 
 
And also, we have provided more customization for GridGroupingControl. Please refer the below KB link, 
 
Please let us know if you have any other queries while using the GridGroupingControl. 
 
Regards, 
Mohanraj G 


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.

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.

;