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.

GGC new row default values

Thread ID:

Created:

Updated:

Platform:

Replies:

78968 Jan 14,2009 10:25 AM Feb 5,2009 08:15 AM Windows Forms 3
loading
Tags: GridControl
Lan Mo
Asked On January 14, 2009 10:25 AM

Hi there,

in GGC control, I want to set default values for some columns when a new row is added.

do you have a new-row-added event in GGC so that I can add code there to populate columns' default values? what is the best way to do that?

Thank you in advance.

Lan




Nisha Arockiya A [Syncfusion]
Replied On January 15, 2009 07:47 AM

Hi Lan,

Thanks for your interest in Syncfusion Products.

The GridGroupingControl has options to have the addnew row in top and at the bottom. If you want to have this only at the bottom, add the below property settings.


this.GridGroupingControl1.TableDescriptor.AllowNew = true;
this.GridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = false;
this.GridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordAfterDetails = true;


To add a new row programmatically in grid, you need to add a new row to the underlying datasource bound to the grid. The Grid just displays the rows from the bounded datasource.

Please try the below code. The below code gets the value for the first two columns from current record in grid and sets some default value to other columns for the new row added.

try
{
Record rec = this.gridGroupingControl1.Table.CurrentRecord;
if (rec != null)
{
object[] obj = new object[] { rec.GetValue("Col0"), rec.GetValue("Col1"), "someval", "someval", "someval" };
CurrencyManager cm = (CurrencyManager)(this.gridGroupingControl1.BindingContext[this.gridGroupingControl1.DataSource, this.gridGroupingControl1.DataMember]);
DataView dv = (DataView)cm.List;
dv.Table.Rows.Add(obj);
this.gridGroupingControl1.Engine.ResetTable();
}
}
catch (Exception ex)
{
throw ex;
}


Please let me know if this serve your needs.

Regards,
Nisha.


Jose
Replied On January 30, 2009 08:43 AM

The code:
" DataView dv = (DataView)cm.List;"
fails because I'm using Linq.
How can I add code there to populate columns default values if I use Linq ?


Nisha Arockiya A [Syncfusion]
Replied On February 5, 2009 08:15 AM


Hi Jose,

Thanks for the Update.

Please refer to the following sample.

\My Documents\Syncfusion\EssentialStudio\6.3.0.24\Windows\Grid.Grouping.Windows\Samples\2.0\FeaturedSamples\LINQGroupBy

Let me know if you find any difficultied.

Regards,
Nisha.


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.

;