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

SaveRecord and GGC

Thread ID:

Created:

Updated:

Platform:

Replies:

57373 Mar 2,2007 10:59 AM UTC Mar 7,2007 08:58 PM UTC WinForms 6
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 2, 2007 10:59 AM UTC

Hi,

I have a GGC which is bound to a business object. The business object contains several properties which are columns in my grid.

Now I have set the CellValueType for each column to "System.String" and during the save operation I want to convert the string to the corresponding data type of the underlying data (my business object property). So I thought there is a SaveRecord event or something else, but I didn't find a suitable one. Can you give me a hint how I can solve my concern?

Administrator [Syncfusion]
Replied On March 2, 2007 08:22 PM UTC

Hi,

You can handle the RecordValueChanging event of the Grid and set the e.NewValue to custom object. Please try the attached sample and let me know if this helps.

private void gridGroupingControl1_RecordValueChanging(object sender, RecordValueChangingEventArgs e)
{
if( e.Column == "CustomObject" )
{
e.NewValue = new Name("NewFirstName","NewLastName");
}
}

Sample : http://websamples.syncfusion.com/samples/Grid.Windows/GGCCustomObject/main.htm

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 5, 2007 02:03 PM UTC

Hi Haneef,

thank you for your fast answer. Is there no way to set the new value in the validating event?

So I am validating with a custom class and later on in the RecordValueChanging event I have to check the same thing again and set the value there. So I am locking for a way to set the value in the validating event.

Any help would be great.

Cheers,
Tom

>Hi,

You can handle the RecordValueChanging event of the Grid and set the e.NewValue to custom object. Please try the attached sample and let me know if this helps.

private void gridGroupingControl1_RecordValueChanging(object sender, RecordValueChangingEventArgs e)
{
if( e.Column == "CustomObject" )
{
e.NewValue = new Name("NewFirstName","NewLastName");
}
}

Sample : http://websamples.syncfusion.com/samples/Grid.Windows/GGCCustomObject/main.htm

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 6, 2007 01:11 AM UTC

Hi Tom,

Please try this code snippet to set a cell value in TableControlCurrentCellValidating event.

private void gridGroupingControl1_TableControlCurrentCellValidating(object sender, GridTableControlCancelEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;
if(style.TableCellIdentity.Column != null &&
style.TableCellIdentity.Column.Name == "CustomObject")
cc.Renderer.ControlValue = new Name("VNewFirstName","VNewLastName");
}

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 6, 2007 07:30 AM UTC

Hi Haneef,

thank you for your answer, but this doesn't seem to work. I have add the corresponding event and the control value of the renderer is set to a new value, but the grid still displays the old value.

I have attached the modified sample.

Thanks in advance

GGCCustomObjectModified.zip

Administrator [Syncfusion]
Replied On March 7, 2007 11:09 AM UTC

Hi,

just wanna bring this thread up - I hope somebody can take a look at this issue again.

Administrator [Syncfusion]
Replied On March 7, 2007 08:58 PM UTC

Hi Tom,

My apologizes for the delay caused on this issue.

You can try this code in a TableControlCurrentCellValidating event of the grid.

void gridGroupingControl1_TableControlCurrentCellValidating(object sender, GridTableControlCancelEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;
if (style.TableCellIdentity.Column != null &&
style.TableCellIdentity.Column.Name == "CustomObject")
{
Name newName = new Name("VNewFirstName", "VNewLastName");
if (cc.Renderer.ControlValue != newName)
{
cc.IsModified = false;
e.TableControl.Table.CurrentRecord.SetValue("CustomObject", newName);
}
}
}

Thanks for your patience.

Best regards,
Haneef

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

;