AS
Asarudheen S
Syncfusion Team
September 27, 2011 04:28 AM UTC
Hi Michal,
Thank you for your interest in Syncfusion products.
Please make use of “ e.Handled = true” in the “SaveCellInfo” event to avoid this problem. It will retained focus to the samec cell if the save action is failed.
Please let me know if I misunderstood your query.
Regards,
Asarudheen.
MR
Michal Recka
October 4, 2011 06:27 AM UTC
Thank you for your answer. I'll try to explain it with some code sample:
private void grid_SaveCellInfo(object sender, GridSaveCellInfoEventArgs e)
{
CellInfo cell = e.Style.Tag as CellInfo;
if (cell == null || cell.CellProperty == null)
return;
if (!SetPropertyValue(cell.CellProperty, e.Style.CellValue, true, true))
{
e.Style.CellValue = cell.CellProperty.Value;
}
e.Handled = true;
grid.RefreshRange(GridRangeInfo.Cell(e.RowIndex, e.ColIndex));
}
private bool SetPropertyValue(Property property, object value, bool sendValueChangingEvent, bool sendValueChangedEvent)
{
if (property == null)
throw new ArgumentException("Property can not be null", "property");
if (property.ValueType != typeof(object))
{
try
{
value = Convert.ChangeType(value, property.ValueType);
}
catch (Exception ex)
{
Errors.Push(new ErrorStackItem(InfoTypes.Error, Core.StrFormat(Resources.errConvertToType, property.ValueType.FullName), ex, "SetPropertyValue", property, value));
}
}
if ((value == null && property.Value != null) || (value != null && !value.Equals(property.Value)))
{
PropertyValueChangeEventArgs e = new PropertyValueChangeEventArgs(property.Name, property.Value, value);
if (sendValueChangingEvent && PropertyValueChanging != null && !PropertyValueChanging(this, e))
return false;
property.Value = value;
if (sendValueChangedEvent && PropertyValueChanged != null)
PropertyValueChanged(this, e);
}
return true;
}
Problem is only when somebody catches an event PropertyValueChanging (my own event) and for example wants user to decide if he wants to accept the change in MessageBox. It doesn't matter if he accepts or not. The TEXT value of cell remains the last displayed text althought the CellValue may be already completely different. (I use also grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) with e.Handled = true) Only thing that seems to help is Refresh() of whole grid which is quite overkill.
AS
Asarudheen S
Syncfusion Team
October 10, 2011 06:32 AM UTC
Hi Michal,
Thanks for the update.
We could not able to obtain your actual intention .Could you please share us more information probably a sample or screen shot which shows your problem,which will be more helpful for us to provide a better solution to you?
Appreciate any additional information.
Regards,
Asarudheen.