Skip to main content
A newer version of this page is available.

ISnapFieldOwner.ParseField(Field) Method

Converts the fields of a RichEditControl to Snap fields.

Namespace: DevExpress.Snap.Core.API

Assembly: DevExpress.Snap.v19.2.Core.dll

Declaration

SnapEntity ParseField(
    Field field
)

Parameters

Name Type Description
field Field

A Field object.

Returns

Type Description
SnapEntity

A SnapEntity descendant.

Remarks

Any modification of a SnapEntity at runtime must be wrapped in the SnapEntity.BeginUpdate and SnapEntity.EndUpdate method calls.

Refer to Snap Fields article for more information about snap fields.

To learn about RichEditControl‘s fields, refer to Fields and Field Codes.

Note

The SnapEntity descendant object cannot be processed after the document has been changed. Call the ParseField method every time the field needs to be modified.

The code sample below shows how to use the ISnapFieldOwner.ParseField method to convert a SnapList’s row template to paragraphs.

using System;
using System.Collections.Generic;
using System.Data;
using DevExpress.Snap.Core.API;

//...

List<DataFieldInfo> dataFields;

void Document_BeforeInsertSnList(object sender, BeforeInsertSnListEventArgs e)
{
    //Fill the data fields collection
    this.dataFields = e.DataFields;
}
void Document_PrepareSnList(object sender, PrepareSnListEventArgs e)
{
    for (int i = 0; i < e.Template.Fields.Count; i++)
    {
        //Convert each field to snap field
        SnapList list = e.Template.ParseField(field) as SnapList;

        //Check whether the returned object is not null
        if(list !=null)
        {
            //Open the snap entity for modification:
            list.BeginUpdate();

            //Clear the list header and row templates:
            list.ListHeader.Delete(list.ListHeader.Range);
            SnapDocument template = list.RowTemplate;
            template.Delete(template.Range);

            //Insert each data field as simple text:
            foreach(DataFieldInfo dataField in this.dataFields)
            {
                template.AppendText(string.Format("{0} = ", dataField.DisplayName));
                template.CreateSnText(template.Range.End, dataField.DataPaths[dataField.DataPaths.Length - 1]);
                template.AppendParagraph();
            }

            //Insert a new paragraph:
            template.AppendParagraph();

            //End the list's update:
            list.EndUpdate();
        }
    }
    this.dataFields = null;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the ParseField(Field) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also