menu

WinForms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class AddNewRecord - WindowsForms API Reference | Syncfusion

    Show / Hide Table of Contents

    Class AddNewRecord

    Defines and implements the class that adds a new record element to the underlying data source. This element represents the empty record that is shown above the table records and / or below the records for each group and implements logic to add new records.

    Inheritance
    System.Object
    Element
    Record
    AddNewRecord
    GridAddNewRecord
    Implements
    System.IDisposable
    ITreeTableCounterSource
    ITreeTableSummaryArraySource
    System.IComparable
    System.ICloneable
    Inherited Members
    Element.ChildTableGroupLevel
    Element.Dispose()
    Element.Disposed
    Element.Disposing
    Element.Engine
    Element.EngineTable
    Element.EnsureInitialized(Object)
    Element.EnsureInitialized(Object, Boolean)
    Element.GetCaptionSection()
    Element.GetCaptionSection(Element)
    Element.GetChildCount()
    Element.GetColumnHeaderSection()
    Element.GetColumnHeaderSection(Element)
    Element.GetCustomPosition()
    Element.GetFilterBar()
    Element.GetFilterBar(Element)
    Element.GetRecord()
    Element.GetRecord(Element)
    Element.GetSummaries(Table)
    Element.GetVisibleCustomPosition()
    Element.GetVisibleInHierarchy()
    Element.GetVisibleInParent()
    Element.GroupLevel
    Element.InDisposed
    Element.Info
    Element.IsCaption()
    Element.IsCaption(Element)
    Element.IsColumnHeader()
    Element.IsColumnHeader(Element)
    Element.IsDisposed
    Element.IsFilterBar()
    Element.IsFilterBar(Element)
    Element.IsRecord()
    Element.IsRecord(Element)
    Element.ITreeTableSummaryArraySource.GetSummaries(ITreeTableEmptySummaryArraySource, Boolean)
    Element.OnDisposed(EventArgs)
    Element.ParentChildTable
    Element.ParentDisplayElement
    Element.ParentElement
    Element.ParentGroup
    Element.ParentRecord
    Element.ParentSection
    Element.ParentTable
    Element.ParentTableDescriptor
    Element.Reserved1
    Element.Reserved10
    Element.Reserved11
    Element.Reserved16a
    Element.Reserved16b
    Element.Reserved16c
    Element.Reserved2
    Element.Reserved3
    Element.Reserved4
    Element.Reserved5
    Element.Reserved6
    Element.Reserved7
    Element.Reserved8
    Element.Reserved9
    Element.TableLevel
    Record.AdjustRecordRowCount()
    Record.AttachToGroup()
    Record.BeginEdit()
    Record.CancelEdit()
    Record.Clone()
    Record.CompareAndUpdateValues()
    Record.CompareTo(Object)
    Record.Delete()
    Record.DetachFromGroup()
    Record.EndEdit()
    Record.EndEdit(Record)
    Record.EnsureValues()
    Record.FieldsToString()
    Record.GetCollapsedVisibleCount()
    Record.GetCounter()
    Record.GetCustomCount()
    Record.GetDisplayElementOffsetOfFirstNestedTable()
    Record.GetExpandedVisibleCount()
    Record.GetNestedTablesVisibleCount()
    Record.GetNextRecord()
    Record.GetOldValue(Int32)
    Record.GetParentRecord(Element)
    Record.GetPreviousRecord()
    Record.GetRecordPreviewRowsVisibleCount()
    Record.GetRecordRowsVisibleCount()
    Record.GetRelatedChildTable(RelationDescriptor)
    Record.GetRelatedRecord(RelationDescriptor)
    Record.GetRelatedRecord(RelationDescriptor, FieldDescriptor, Object)
    Record.GetSourceIndex()
    Record.GetSummaries(Table, Boolean)
    Record.GetUniformChildListSourceIndex()
    Record.GetValue(SortColumnDescriptor)
    Record.GetValue(String)
    Record.GetVisibleCount()
    Record.GetVisibleCustomCount()
    Record.GetYAmountCount()
    Record.HasNestedTables
    Record.Id
    Record.InvalidateCounter()
    Record.InvalidateCounterBottomUp()
    Record.InvalidateCounterTopDown(Boolean)
    Record.InvalidateSummariesBottomUp()
    Record.InvalidateSummariesTopDown()
    Record.InvalidateSummary()
    Record.IsChildVisible(Element)
    Record.IsCollapsible
    Record.IsCurrent
    Record.IsEditing
    Record.IsExpanded
    Record.IsInitialized
    Record.Item[String]
    Record.NestedTables
    Record.OnCancelEditCalled()
    Record.OnElementTreeInvalidateCounterBottomUp()
    Record.OnEnsureInitialized(Object)
    Record.OnEnterRecordComplete(Boolean)
    Record.OnLeaveRecordCalled()
    Record.OnLeaveRecordComplete(Boolean)
    Record.Parent
    Record.ParentDetails
    Record.PrimaryKeys
    Record.RecordParts
    Record.RecordPreviewRows
    Record.RecordRows
    Record.ReinsertRecord()
    Record.ResetValues()
    Record.SetCurrent()
    Record.SetCurrent(String)
    Record.SetExpanded(Boolean, Boolean, Boolean)
    Record.SetSelectedRecursive(Boolean)
    Record.SetSourceIndex(Int32, Int32, Object)
    Record.SetValue(String, Object)
    Record.ShouldShowRecordPreviewRows()
    Record.ShouldShowRecordRows()
    Record.SortKeys
    Record.SupportsId()
    Record.ToString()
    Record.UpdatePrimaryKeys(Boolean, SortColumnDescriptor[], PropertyDescriptor[])
    Record.UpdateSortInfo(Boolean, SortColumnDescriptor[], PropertyDescriptor[])
    Record.UpdateValues(IEnumerable)
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: Syncfusion.Grouping
    Assembly: Syncfusion.Grouping.Base.dll
    Syntax
    public class AddNewRecord : Record, IDisposable, IDisposedEvent, IIsDisposedProperty, ITreeTableCounterSource, ITreeTableSummaryArraySource, IContainerElement, IElementTreeTableSource, IElement, IComparable, ICloneable
    Remarks

    This element represents the empty record that is shown above the table records and / or below the records for each group and implements logic to add new records.

    The class is derived from Record. It adds special behavior such that the AddNewRecord is not bound to a record in the underlying table. Instead all fields are initially empty ( or default values based on parent group by criteria). When changes are made, the changes will be committed to the underlying table by adding a new record at the end of the underlying data source. The grouping engine will automatically insert the record into its sorted records collection and insert it into the group it belongs to. If no group is found where the record fits in, a new group will be created on the fly.

    AddNewRecord(s) can be optionally displayed at the start of table below the column headers and / or at the end of each group.

    AddNewRecord belongs to an AddNewRecordSection and is its only element.

    If AddNewRecord(s) should be displayed at end of each group (see also Engine.ShowAddNewRecordInGroups), then AddNewRecordSection(s) are created when the grouping for a table is initialized. The grouping engine loops through all sorted records and categorizes them. For each new group, the virtual TableDescriptor.CreateGroup factory method is called. The TableDescriptor.CreateGroup method instantiates an AddNewRecordSection by calling the virtual TableDescriptor.CreateAddNewRecordSection factory method.

    One AddNewRecord is displayed at the top of the table below the column headers. It belongs to the AddNewRecordSection of the TopLevelGroup of a table. The TopLevelGroup is created with the virtual TableDescriptor.CreateGroup factory method. The TableDescriptor.CreateGroup method instantiates an AddNewRecordSection by calling the virtual TableDescriptor.CreateAddNewRecordSection factory method.

    AddNewRecord is a container element. It contains one or multiple RecordParts.

    Because the AddNewRecord is a container element and not a display element, it will not be an item returned by the Table.DisplayElements and Table.GroupedElements collection. Instead, AddNewRecord is only returned by the RecordsDetails.Records collection of its parent AddNewRecordSection (or the Group.Records collection of its ParentGroup which is a shortcut instead of accessing it through AddNewRecordSection).

    See also the Engine.RecordAsDisplayElements how to make AddNewRecord be treated as a display element if you have no need for nested elements within a record., e.g. if you only want to display a single table and you do not need multiple row elements per record and / or nested tables. (However, do not change this setting if you intend to use the engine as grid data model.)

    The first record part is a RecordRowsPart. A RecordRowsPart contains one or multiple RecordRows displayed in a grid for the record.

    The second record part represents nested tables. If relations have been defined for the table (see TableDescriptor.Relations) and the current table has a foreign key relationship setup to other tables, a table is added to the RecordPart[1].NestedTables collection for each relation. You can access nested tables in a record with the Record.NestedTables collection.

    AddNewRecord can be set as the current record in a table if you want to edit its data through the engine.

    The first time a value is changed by the grid, Record.BeginEdit is called before the value is assigned. When the user moves the current cell in the grid to a new record, the changes are committed with a Record.EndEdit call. If the user presses Escape, the changes are rolled back with a Record.CancelEdit call. If the user presses Enter, the changes are committed and the record's new display position is determined and the current cell is moved to the new display position of the record. If validation fails during EndEdit, the grid will try to identify the column which violated the record constraints and display a red error indicator for that column with a ToolTip text showing the exception text when the user hovers the mouse over the red arrow indicator.

    See the CurrentRecordManager class for a description of events raised when modifying columns in the AddNewRecord row or when BeginEdit, CancelEdit or EndEdit was called.

    See also: CurrentRecordManager, CurrentRecordManager.IsAddNewRecord, CurrentRecordManager.NavigateTo, Group.AddNewRecord, Table.AddNewRecord, TableDescriptor.CreateGroup, Table.TopLevelGroup, AddNewRecordSection, IContainerElement, RecordsDetails.Records, Group.Records

    Examples

    The following example shows how you can add record and keep track of its sorted display position within the table:

                // Add a record to Table table2.
                Record r = table2.AddNewRecord;
                r.SetCurrent();   // Makes it the current record, saving any pending changes previous current record.
                if (r.IsCurrent)
                {
                    r.BeginEdit();
                    if (r.IsEditing)
                    {
                        r.SetValue("Country", "USA");
                        r.SetValue("Region", "NC");
                        r.SetValue("CustomerID", "SYNC
                        r.SetValue("CompanyName", "Syncfusion");
                        r.EndEdit();
                    }
                }
    

    int displayPos = table2.DisplayElements.IndexOf(r); // Now, you can navigate the current cell of a grid to row displayPos and highlight the newly added row // within its correct group category and sort order.

    Constructors

    AddNewRecord(AddNewRecordSection)

    Initializes the new instances of the AddNewRecord class in the specified AddNewRecordSection.

    Declaration
    public AddNewRecord(AddNewRecordSection parent)
    Parameters
    Type Name Description
    AddNewRecordSection parent

    The parent that this element belongs to.

    Properties

    Kind

    Gets the value of the display element kind.

    Declaration
    public override DisplayElementKind Kind { get; }
    Property Value
    Type
    DisplayElementKind
    Overrides
    Record.Kind

    UseDefaultValueInGetValue

    Gets or sets the value of the AddNewRecord indicating whether it should retrieve the default value when its GetValue method is called.

    Declaration
    public bool UseDefaultValueInGetValue { get; set; }
    Property Value
    Type
    System.Boolean
    Remarks

    If UseDefaultValueInGetValue is false and also Engine.ShowDefaultValuesInAddNewRecord is false then the default values will only be assigned when AddNewRecord.BeginEdit is called. Prior calls to GetValue will return no value.

    Methods

    Dispose(Boolean)

    Overrides and manages the unwanted resources.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing
    Overrides
    Record.Dispose(Boolean)

    GetData()

    Overrides and returns the record data.

    Declaration
    public override object GetData()
    Returns
    Type Description
    System.Object

    Record data.

    Overrides
    Record.GetData()

    GetElementCount()

    Overrides and gets the number of elements.

    Declaration
    public override int GetElementCount()
    Returns
    Type Description
    System.Int32

    Element count.

    Overrides
    Record.GetElementCount()

    GetFilteredRecordCount()

    Overrides and gets the count of filtered records.

    Declaration
    public override int GetFilteredRecordCount()
    Returns
    Type Description
    System.Int32

    Number of filtered records.

    Overrides
    Record.GetFilteredRecordCount()

    GetRecordCount()

    Overrides and gets the number of records.

    Declaration
    public override int GetRecordCount()
    Returns
    Type Description
    System.Int32

    Record count.

    Overrides
    Record.GetRecordCount()

    GetValue(FieldDescriptor)

    Overrides and gets the value for the field specified.

    Declaration
    public override object GetValue(FieldDescriptor fieldDescriptor)
    Parameters
    Type Name Description
    FieldDescriptor fieldDescriptor

    The descriptor of the field whose value is to be fetched.

    Returns
    Type Description
    System.Object

    Requested field value.

    Overrides
    Record.GetValue(FieldDescriptor)

    IsSelected()

    Overrides and determines whether the record is selected or not.

    Declaration
    public override bool IsSelected()
    Returns
    Type Description
    System.Boolean

    Returns false.

    Overrides
    Record.IsSelected()

    MeetsFilterCriteria()

    Overrides and determines whether the record meets the filter criteria or not.

    Declaration
    public override bool MeetsFilterCriteria()
    Returns
    Type Description
    System.Boolean

    Returns True.

    Overrides
    Record.MeetsFilterCriteria()

    OnBeginEditCalled()

    Overrides and determines to support edit the added new record.

    Declaration
    public override bool OnBeginEditCalled()
    Returns
    Type Description
    System.Boolean

    IfTrueediting new record can proceed;Otherwise False.

    Overrides
    Record.OnBeginEditCalled()

    OnBeginEditComplete(Boolean)

    Overrides and called when the BeginEdit() successfully finishes.

    Declaration
    public override void OnBeginEditComplete(bool success)
    Parameters
    Type Name Description
    System.Boolean success

    IfTrueit is successfully finished;Otherwise False.

    Overrides
    Record.OnBeginEditComplete(Boolean)

    OnCancelEditComplete(Boolean)

    Overrides and called when the CancelEdit() successfully finishes.

    Declaration
    public override void OnCancelEditComplete(bool success)
    Parameters
    Type Name Description
    System.Boolean success

    IfTrueit is successfully finished;Otherwise False.

    Overrides
    Record.OnCancelEditComplete(Boolean)

    OnEndEditCalled()

    Overrides and determines whether the EndEdit() method can be called or not.

    Declaration
    public override bool OnEndEditCalled()
    Returns
    Type Description
    System.Boolean

    IfTrue then EndEdit() can proceed;Otherwise False.

    Overrides
    Record.OnEndEditCalled()

    OnEndEditComplete(Boolean)

    Overrides and called when EndEdit() successfully finishes.

    Declaration
    public override void OnEndEditComplete(bool success)
    Parameters
    Type Name Description
    System.Boolean success

    IfTrueit is successfully finished;Otherwise False.

    Overrides
    Record.OnEndEditComplete(Boolean)

    OnEnterRecordCalled()

    Overrides and determines if the source list allows adding new record.

    Declaration
    public override bool OnEnterRecordCalled()
    Returns
    Type Description
    System.Boolean

    IfTrue new record is allowed; Otherwise False.

    Overrides
    Record.OnEnterRecordCalled()

    SetSelected(Boolean)

    Overrides and sets the record as selected.

    Declaration
    public override void SetSelected(bool value)
    Parameters
    Type Name Description
    System.Boolean value

    IfTruethe record should be marked as selected;Otherwise False.

    Overrides
    Record.SetSelected(Boolean)

    SetValue(FieldDescriptor, Object)

    Sets a value for the given field.

    Declaration
    public override void SetValue(FieldDescriptor fieldDescriptor, object value)
    Parameters
    Type Name Description
    FieldDescriptor fieldDescriptor

    The field descriptor.

    System.Object value

    The Value.

    Overrides
    Record.SetValue(FieldDescriptor, Object)
    Exceptions
    Type Condition
    System.NotSupportedException

    If the field consists of invalid field name.

    System.InvalidOperationException

    Add new record is not performed.

    Implements

    System.IDisposable
    ITreeTableCounterSource
    ITreeTableSummaryArraySource
    System.IComparable
    System.ICloneable
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved