WinForms

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class GridAddNewRecord

    Show / Hide Table of Contents

    Class GridAddNewRecord

    A record element for adding new records 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
    IGridTableCellAppearanceSource
    IGridTableCellStyleChanged
    Inherited Members
    AddNewRecord.GetData()
    AddNewRecord.GetValue(FieldDescriptor)
    AddNewRecord.SetValue(FieldDescriptor, Object)
    AddNewRecord.OnEnterRecordCalled()
    AddNewRecord.OnBeginEditCalled()
    AddNewRecord.OnBeginEditComplete(Boolean)
    AddNewRecord.OnCancelEditComplete(Boolean)
    AddNewRecord.OnEndEditCalled()
    AddNewRecord.OnEndEditComplete(Boolean)
    AddNewRecord.GetFilteredRecordCount()
    AddNewRecord.GetRecordCount()
    AddNewRecord.GetElementCount()
    AddNewRecord.MeetsFilterCriteria()
    AddNewRecord.IsSelected()
    AddNewRecord.SetSelected(Boolean)
    AddNewRecord.Kind
    AddNewRecord.UseDefaultValueInGetValue
    Record.SupportsId()
    Record.GetDisplayElementOffsetOfFirstNestedTable()
    Record.GetExpandedVisibleCount()
    Record.GetCollapsedVisibleCount()
    Record.GetNestedTablesVisibleCount()
    Record.GetRecordRowsVisibleCount()
    Record.GetRecordPreviewRowsVisibleCount()
    Record.Delete()
    Record.SetCurrent()
    Record.SetCurrent(String)
    Record.BeginEdit()
    Record.EndEdit()
    Record.EndEdit(Record)
    Record.CancelEdit()
    Record.GetValue(SortColumnDescriptor)
    Record.SetValue(String, Object)
    Record.GetValue(String)
    Record.InvalidateSummariesBottomUp()
    Record.GetSourceIndex()
    Record.SetSourceIndex(Int32, Int32, Object)
    Record.GetUniformChildListSourceIndex()
    Record.SetSelectedRecursive(Boolean)
    Record.UpdateSortInfo(Boolean, SortColumnDescriptor[], PropertyDescriptor[])
    Record.UpdatePrimaryKeys(Boolean, SortColumnDescriptor[], PropertyDescriptor[])
    Record.GetSummaries(Table, Boolean)
    Record.GetNextRecord()
    Record.GetPreviousRecord()
    Record.DetachFromGroup()
    Record.AttachToGroup()
    Record.ReinsertRecord()
    Record.InvalidateCounter()
    Record.OnElementTreeInvalidateCounterBottomUp()
    Record.GetVisibleCount()
    Record.GetCounter()
    Record.GetYAmountCount()
    Record.GetCustomCount()
    Record.GetVisibleCustomCount()
    Record.IsChildVisible(Element)
    Record.ShouldShowRecordRows()
    Record.SetExpanded(Boolean, Boolean, Boolean)
    Record.InvalidateCounterTopDown(Boolean)
    Record.InvalidateCounterBottomUp()
    Record.OnEnsureInitialized(Object)
    Record.InvalidateSummariesTopDown()
    Record.InvalidateSummary()
    Record.FieldsToString()
    Record.ToString()
    Record.OnCancelEditCalled()
    Record.OnLeaveRecordCalled()
    Record.OnLeaveRecordComplete(Boolean)
    Record.OnEnterRecordComplete(Boolean)
    Record.GetRelatedRecord(RelationDescriptor)
    Record.GetRelatedRecord(RelationDescriptor, FieldDescriptor, Object)
    Record.GetRelatedChildTable(RelationDescriptor)
    Record.GetParentRecord(Element)
    Record.AdjustRecordRowCount()
    Record.CompareTo(Object)
    Record.EnsureValues()
    Record.ResetValues()
    Record.GetOldValue(Int32)
    Record.CompareAndUpdateValues()
    Record.UpdateValues(IEnumerable)
    Record.Clone()
    Record.Id
    Record.Item[String]
    Record.RecordParts
    Record.IsCurrent
    Record.IsEditing
    Record.Parent
    Record.ParentDetails
    Record.SortKeys
    Record.PrimaryKeys
    Record.IsInitialized
    Record.IsExpanded
    Record.HasNestedTables
    Record.RecordRows
    Record.RecordPreviewRows
    Record.NestedTables
    Element.Dispose()
    Element.OnDisposed(EventArgs)
    Element.EnsureInitialized(Object)
    Element.EnsureInitialized(Object, Boolean)
    Element.GetSummaries(Table)
    Element.GetVisibleInParent()
    Element.GetVisibleInHierarchy()
    Element.GetChildCount()
    Element.GetCustomPosition()
    Element.GetVisibleCustomPosition()
    Element.ITreeTableSummaryArraySource.GetSummaries(ITreeTableEmptySummaryArraySource, Boolean)
    Element.IsCaption(Element)
    Element.IsRecord(Element)
    Element.IsColumnHeader(Element)
    Element.IsFilterBar(Element)
    Element.IsCaption()
    Element.IsRecord()
    Element.IsColumnHeader()
    Element.IsFilterBar()
    Element.GetCaptionSection(Element)
    Element.GetRecord(Element)
    Element.GetColumnHeaderSection(Element)
    Element.GetFilterBar(Element)
    Element.GetCaptionSection()
    Element.GetRecord()
    Element.GetColumnHeaderSection()
    Element.GetFilterBar()
    Element.TableLevel
    Element.Reserved1
    Element.Reserved2
    Element.Reserved3
    Element.Reserved4
    Element.Reserved5
    Element.Reserved6
    Element.Reserved7
    Element.Reserved8
    Element.Reserved9
    Element.Reserved10
    Element.Reserved11
    Element.Reserved16a
    Element.Reserved16b
    Element.Reserved16c
    Element.Info
    Element.Disposing
    Element.IsDisposed
    Element.InDisposed
    Element.ParentElement
    Element.ParentDisplayElement
    Element.ParentGroup
    Element.ParentSection
    Element.GroupLevel
    Element.ChildTableGroupLevel
    Element.Disposed
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Syncfusion.Windows.Forms.Grid.Grouping
    Assembly: Syncfusion.Grid.Grouping.Windows.dll
    Syntax
    public class GridAddNewRecord : AddNewRecord, IDisposable, IDisposedEvent, IIsDisposedProperty, ITreeTableCounterSource, ITreeTableSummaryArraySource, IContainerElement, IElementTreeTableSource, IElement, IComparable, ICloneable, IGridTableCellAppearanceSource, IGridTableCellStyleChanged
    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 a 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, they 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 into the group it belongs to. If no group is found where the record fits in, a new group will be created.

    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 a 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 a 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 AddNewRecord is a container element and not a display element and 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 on 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 records and keep track of sorted display positions within a 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 = table.DisplayElements.IndexOf(r); // Now, you could 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

    GridAddNewRecord(AddNewRecordSection)

    Initializes the new instance of the GridAddNewRecord class.

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

    The parent that this element belongs to.

    Properties

    Appearance

    Gets or sets the default GridTableCellAppearance with GridTableCellStyleInfo information for cells of this element.

    Declaration
    public GridTableCellAppearance Appearance { get; set; }
    Property Value
    Type Description
    GridTableCellAppearance

    Engine

    Gets the engine this element belongs to.

    Declaration
    public GridEngine Engine { get; }
    Property Value
    Type Description
    GridEngine

    EngineTable

    Gets the reference to the GridTable of the Engine this element belongs to.

    Declaration
    public GridTable EngineTable { get; }
    Property Value
    Type Description
    GridTable

    IsCollapsible

    Gets the current element is collapsible.

    Declaration
    public override bool IsCollapsible { get; }
    Property Value
    Type Description
    System.Boolean
    Overrides
    Record.IsCollapsible

    ParentChildTable

    Gets a reference to the child table this element belongs.

    Declaration
    public GridChildTable ParentChildTable { get; }
    Property Value
    Type Description
    GridChildTable

    ParentRecord

    Gets a reference to the parent record this element belongs to.

    Declaration
    public GridRecord ParentRecord { get; }
    Property Value
    Type Description
    GridRecord

    ParentTable

    Gets a reference to the parent table this element belongs to.

    Declaration
    public GridTable ParentTable { get; set; }
    Property Value
    Type Description
    GridTable

    ParentTableDescriptor

    Gets the table descriptor this element belongs to.

    Declaration
    public GridTableDescriptor ParentTableDescriptor { get; }
    Property Value
    Type Description
    GridTableDescriptor

    ReadOnlyAppearance

    If this element is modified, the Appearance returns this object's Appearance; otherwise it returns a GridTableCellAppearance of the first parent element with appearance in the hierarchy.

    Declaration
    public GridTableCellAppearance ReadOnlyAppearance { get; }
    Property Value
    Type Description
    GridTableCellAppearance

    Methods

    Dispose(Boolean)

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

    GetBaseAppearance()

    Returns a GridTableCellAppearance of the first parent element with appearance in the hierarchy.

    Declaration
    public GridTableCellAppearance GetBaseAppearance()
    Returns
    Type Description
    GridTableCellAppearance

    A GridTableCellAppearance.

    ResetAppearance()

    Discards any changes for the Appearance object.

    Declaration
    public void ResetAppearance()

    ShouldSerializeAppearance()

    Determines whether Appearance has been modified and contents should be serialized at design-time.

    Declaration
    public bool ShouldSerializeAppearance()
    Returns
    Type Description
    System.Boolean

    True if contents were changed; False otherwise.

    ShouldShowRecordPreviewRows()

    Indicates whether to show the record preview rows.

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

    returns the boolean value False.

    Overrides
    Record.ShouldShowRecordPreviewRows()

    Explicit Interface Implementations

    IGridTableCellAppearanceSource.GetAppearance()

    Declaration
    GridTableCellAppearance IGridTableCellAppearanceSource.GetAppearance()
    Returns
    Type Description
    GridTableCellAppearance

    IGridTableCellAppearanceSource.RaiseAppearanceChanged(GridTableCellStyleInfoChangedEventArgs)

    Declaration
    void IGridTableCellAppearanceSource.RaiseAppearanceChanged(GridTableCellStyleInfoChangedEventArgs e)
    Parameters
    Type Name Description
    GridTableCellStyleInfoChangedEventArgs e

    IGridTableCellAppearanceSource.RaiseAppearanceChanging(GridTableCellStyleInfoChangedEventArgs)

    Declaration
    void IGridTableCellAppearanceSource.RaiseAppearanceChanging(GridTableCellStyleInfoChangedEventArgs e)
    Parameters
    Type Name Description
    GridTableCellStyleInfoChangedEventArgs e

    IGridTableCellStyleChanged.RaiseTableCellStyleChanged(GridTableCellStyleInfoEventArgs)

    Declaration
    void IGridTableCellStyleChanged.RaiseTableCellStyleChanged(GridTableCellStyleInfoEventArgs e)
    Parameters
    Type Name Description
    GridTableCellStyleInfoEventArgs e

    Implements

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