ISnapFieldOwner.ParseField(Field) Method

Converts the fields of a RichEditControl to Snap fields.

Namespace: DevExpress.Snap.Core.API

Assembly: DevExpress.Snap.v20.1.Core.dll

Declaration

SnapEntity ParseField(
    Field field
)
Function ParseField(
    field As Field
) As SnapEntity

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.Paragraphs.Append();
            }

            //Insert a new paragraph:
            template.Paragraphs.Append();

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