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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

TableControlCurrentCellValidating being called twice for same operation

Thread ID:

Created:

Updated:

Platform:

Replies:

56139 Feb 9,2007 06:42 PM UTC Feb 21,2007 03:20 AM UTC WinForms 5
loading
Tags: Grouping
James Blibo
Asked On February 9, 2007 06:42 PM UTC

I have a cell in which a user can enter a have and press the enter key. I then do so validation in the TableControlCurrentCellValidating event.

However, I noticed that the TableControlCurrentCellValidating is being called twice for the same operation. When I enetr a value in the cell, the is called and they called again, causing the adverse effect in my logic.

I have something like this in the event..

... if logic is true then..

this.gridGroupingControl1.TableControl.BeginUpdate();


DataRow rowLine = rec.GetData() as DataRow;
rowLine.BeginEdit();
rowLine[columnName] = NewWeekSpot;
rowLine.EndEdit();

e.TableControl.Table.CurrentRecord.EndEdit();


this.gridGroupingControl1.TableControl.EndUpdate(true);

Administrator [Syncfusion]
Replied On February 14, 2007 01:00 AM UTC

Hi James,

I am not sure of what be might be causing this strange behavior without a working sample. I have tested this issue in the attached sample with Essentail studio V.4.x. I was not able to reproduce the issue. Maybe I am not following the steps that you are doing. Please post us a sample showing this problem or modify the attached samples to reproduce the problem, which will help me to find the issue and resolve this.

GGCValidateCell.zip

Thanks for your patience.

Best regards,
Haneef

James Blibo
Replied On February 19, 2007 07:04 AM UTC

I have been able to reproduce this issue in the sample that you sent.

I the sample that you sent, you have the following code in the TableControlCurrentCellValidating event...

e.TableControl.BeginUpdate();
Record rec = e.TableControl.Table.CurrentRecord;
DataRowView row = rec.GetData() as DataRowView;
row.BeginEdit();
row["Col1"] = NewValue;
row.EndEdit();
e.TableControl.Table.CurrentRecord.EndEdit();
e.TableControl.EndUpdate(true);


... noticed how you are first casting to a DataRowView before you are made the change to the record.

... However, in my code, I am doing the following...

e.TableControl.BeginUpdate();
Record rec = e.TableControl.Table.CurrentRecord;
rec.BeginEdit();
rec.SetValue("Col1", NewValue);
rec.EndEdit();
e.TableControl.Table.CurrentRecord.EndEdit();
e.TableControl.EndUpdate(true);


...this is when the TableControlCurrentCellValidating is raised TWICE. I see nothing wrong with editing the record thru SetValue, but oviously, this is causing the TableConrolCurrentCellValidating to be raised twice

Administrator [Syncfusion]
Replied On February 20, 2007 09:55 PM UTC

Hi James,

Sorry for the delay in responding to your query.

To resolve this issue, you need to set the CurrentCell.IsModified property to false in the TableControlCurrentCellValidating event of the grid. Please refer to the attached sample for implementation and let me know if this helps.

e.TableControl.BeginUpdate();
Record rec = e.TableControl.Table.CurrentRecord;
rec.BeginEdit();

cc.IsModified = false;

rec.SetValue("Col1", NewValue);
rec.EndEdit();
e.TableControl.Table.CurrentRecord.EndEdit();
e.TableControl.EndUpdate(true);

Sample : Modifiedissue23.zip

Best regards,
Haneef

James Blibo
Replied On February 21, 2007 03:10 AM UTC

What if I have a situation where I am looping thru a record collection and updating a field, the solution that you provided will not work...

If I have something like this...

foreach (Record record in filterSpotRecords) //update child grid
{
record.BeginEdit();

record.SetValue("Length", NewSpotLength);
record.SetValue("CurrentRate", NewRate);
record.EndEdit();
}
versus...

e.TableControl.BeginUpdate();
Record rec = e.TableControl.Table.CurrentRecord;
rec.BeginEdit();
cc.IsModified = false;
rec.SetValue("Col1", NewValue);
rec.EndEdit();
e.TableControl.Table.CurrentRecord.EndEdit();
e.TableControl.EndUpdate(true);

....


How can I set cc.IsModified = true?

This will still cause the TableControlCurrentCellValidation event to be raise twice.

James Blibo
Replied On February 21, 2007 03:20 AM UTC

Never mind my previous post... the event will only be raise for the current cell, so no need for me to worry about updating other records in the datasource... thx for the help

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.

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

;