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.

SaveRecord and GGC

Thread ID:

Created:

Updated:

Platform:

Replies:

57373 Mar 2,2007 05:59 AM Mar 7,2007 03:58 PM Windows Forms 6
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 2, 2007 05:59 AM

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 03:22 PM

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 09:03 AM

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 5, 2007 08:11 PM

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 02:30 AM

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 06:09 AM

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 03:58 PM

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.

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.

;