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.

How to set the GridAddNewRecord as the current record in GGC

Thread ID:

Created:

Updated:

Platform:

Replies:

57407 Mar 2,2007 04:28 PM Mar 6,2007 11:14 AM Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 2, 2007 04:28 PM

Hi,
Can you help? I have a method that will be used to add new records to GGC, but I need that record to be the current record so that text boxes linked to it will show what is being added on a per cell basis.

Is there a way to do this?

Thanks!

Administrator [Syncfusion]
Replied On March 2, 2007 05:48 PM

Hi,

You can use the UnsortedRecords property to find the newly record and set that record as current record using the SetCurrent method. Below is a code snippet

int Oldcount = this.gridGroupingControl1.Table.UnsortedRecords.Count;

DataTable dt = this.gridGroupingControl1.DataSource as DataTable;
DataRow dr = dt.NewRow();
dr["Col1"] = "NewValue";
dt.Rows.Add(dr);
dt.AcceptChanges();

this.gridGroupingControl1.Table.UnsortedRecords[Oldcount].SetCurrent("ColumnName");
this.gridGroupingControl1.Table.UnsortedRecords[Oldcount].SetSelected(true);

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 2, 2007 06:12 PM

Thanks; Actually, what I mean is the row for new records (with the *), the GridAddNewRecord, which I guess has cells of type GridTableCellType.AddNewRecordFieldCell -
I want to be able to 'see' the events (data entry) in that row and display them in text boxes, so I need it to be the current record...

Thanks again!

>Hi,

You can use the UnsortedRecords property to find the newly record and set that record as current record using the SetCurrent method. Below is a code snippet

int Oldcount = this.gridGroupingControl1.Table.UnsortedRecords.Count;

DataTable dt = this.gridGroupingControl1.DataSource as DataTable;
DataRow dr = dt.NewRow();
dr["Col1"] = "NewValue";
dt.Rows.Add(dr);
dt.AcceptChanges();

this.gridGroupingControl1.Table.UnsortedRecords[Oldcount].SetCurrent("ColumnName");
this.gridGroupingControl1.Table.UnsortedRecords[Oldcount].SetSelected(true);

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 5, 2007 06:36 PM

Hi,

One way you can do this by handling the CurrentRecordContextChange event of the grid and call the Table.AddNew method followed by AddNewRecord.BeginEdit() method. Here is a code snippet.

private void gridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)
{
if( e.Action == Syncfusion.Grouping.CurrentRecordAction.EndEditComplete
&& e.Record.Kind == DisplayElementKind.AddNewRecord)
{
e.Table.BeginEdit();
e.Table.AddNew();
e.Table.AddNewRecord.BeginEdit();
}
}

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 5, 2007 08:08 PM

Thanks Haneef - will try it.

>Hi,

One way you can do this by handling the CurrentRecordContextChange event of the grid and call the Table.AddNew method followed by AddNewRecord.BeginEdit() method. Here is a code snippet.

private void gridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)
{
if( e.Action == Syncfusion.Grouping.CurrentRecordAction.EndEditComplete
&& e.Record.Kind == DisplayElementKind.AddNewRecord)
{
e.Table.BeginEdit();
e.Table.AddNew();
e.Table.AddNewRecord.BeginEdit();
}
}

Best regards,
Haneef

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

Hi Haneef,
I tried this and the event is triggered, but the record I add doesn't stay. After I hit 'enter', the AddNew method is called, but no new record shows up. What could be the cause?

Thanks again,




>Thanks Haneef - will try it.

>Hi,

One way you can do this by handling the CurrentRecordContextChange event of the grid and call the Table.AddNew method followed by AddNewRecord.BeginEdit() method. Here is a code snippet.

private void gridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)
{
if( e.Action == Syncfusion.Grouping.CurrentRecordAction.EndEditComplete
&& e.Record.Kind == DisplayElementKind.AddNewRecord)
{
e.Table.BeginEdit();
e.Table.AddNew();
e.Table.AddNewRecord.BeginEdit();
}
}

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.

;