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.

Adding a new record to GridGroupingControl with AllowNew = true;

Thread ID:

Created:

Updated:

Platform:

Replies:

50020 Oct 3,2006 01:54 PM Oct 5,2006 03:01 AM Windows Forms 5
loading
Tags: GridControl
Alexander
Asked On October 3, 2006 01:54 PM

If I set for my GridGroupingControl such properties as:

gridGroupingControl1.TableDescriptor.AllowNew = true;
gridGroupingControl1.TableDescriptor.AllowEdit = true;

In the top oof my grid appears the row for adding new records to my grid and to my DataTable also that was binded to that grid, and why when I input only one value to some column and set focus to the next cell in this row - grid automaticaly adds this not completed record with values to the end of his collection and it appears as new added as last record - and how can I to control adding the new record to my grid, how can I Cancel(Reject) the adding if my record edditing is not completed yet???

Best regards, Alexander.

Administrator [Syncfusion]
Replied On October 4, 2006 02:13 AM

Hi Alexander,

You need to handle the CurrentRecordContextChange event and set the e.Cancel to TRUE when the record is incomplete. Below is a code snippet

private void gridCurrentRecordContextChange(object sender, CurrentRecordContextChangeEventArgs e)
{
if( e.Record != null && e.Record.Kind == DisplayElementKind.AddNewRecord
&& e.Action == CurrentRecordAction.EndEditCalled )
{
DataRowView drv = e.Record.GetData() as DataRowView;

for(int i = 0 ;i < drv.Row.ItemArray.Length; i++)
{
object cellvalue = drv[i];
if( cellvalue == null || cellvalue.ToString() == string.Empty )
{
e.Cancel = true;
break;
}
}
}
}

Thanks,
Haneef

Alexander
Replied On October 4, 2006 07:00 AM

Thanks it is work okey!!!

But how I can to set value programmaticaly in this new row until it is not added to the grid collection???

When I try to do this:

gridGroupingControl1.TableControl.Table.CurrentRecord.SetValue("Candidate_id", 33);

an error occured(exception) - this row hasn''t been added!!!

Administrator [Syncfusion]
Replied On October 4, 2006 08:11 AM

Hi Alexander,

Try these code snippet to set the newvalue to the AddNewRecord of the GridTable.

GridTable table = this.gridGroupingControl1.GetTable("YourTableName");
table.BeginEdit();

Record r = null;
foreach(Element el in table.DisplayElements)
{
if( el.Kind == DisplayElementKind.AddNewRecord )
{
r = el.ParentRecord;
r.SetCurrent();
if( r != null)
{
if (r.IsCurrent)
{
r.BeginEdit();
if (r.IsEditing)
{
r.SetValue("YourColumnName", "BX");
r.SetValue("YourColName", "ID");
//If you want to add the record to the table call EndEdit...
//r.EndEdit();
}
}
}
break;
}
}
//If you want to add the record to the table call EndEdit...
//table.EndEdit();


Best Regards,
Haneef

Alexander
Replied On October 4, 2006 10:36 AM

Is the RowCount in GridGroupingControl of the NewRow(row for adding new records) is always equal(=) 4(four)???

Or how can I to know is NewRow in Grid now is editing????

Administrator [Syncfusion]
Replied On October 5, 2006 03:01 AM

Hi Alexander,

Is the RowCount in GridGroupingControl of the NewRow(row for adding new records) is always equal(=) 4(four)???
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
No. It depends on the GroupCaptionRow, ColumnHeaderRow and display order of the GroupingEngine.

How can I to know is NewRow in Grid now is editing????

>>>>>>>>>>>>>>>>
You can use the IsEditing property of the Record to determine the editing state of the record.

this.grid.Table.AddNewRecord.IsEditing.

//For 4th record
this.grid.Table.Records[4].IsEditing.

Thanks,
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.

;