Skip to main content
All docs
V26.1
  • GroupField Class

    A form field that organizes other form fields into groups in a PDF document.

    Namespace: DevExpress.Docs.Pdf

    Assembly: DevExpress.Docs.Pdf.v26.1.dll

    NuGet Package: DevExpress.Docs.Pdf

    Declaration

    public class GroupField :
        FormField

    The following members return GroupField objects:

    Example

    How to: Group Form Fields in a PDF Document

    using DevExpress.Docs.Pdf;
    using DevExpress.Drawing.Printing;
    
    using System.Drawing;
    
    namespace ConsoleApp1;
    
    public class Program {
        public static async Task Main(string[] _) {
            using (PdfDocument pdfDocument = new()) {
                // Add an A4 page to the document.
                Page page = pdfDocument.Pages.Add(DXPaperKind.A4);
    
                // Create a font for field labels.
                TextFont textFont = new("Arial", TextFontStyle.Regular);
    
                float y = 750;
                float step = 30;
                float textHeight = 20f;
    
                // Create a label for the first name field.
                TextFragment firstNLabel = new() {
                    Text = "First name:",
                    Location = new PointF(50, y - textHeight / 2),
                    Font = textFont
                };
                page.Fragments.Add(firstNLabel);
    
                // Create the first name field and bind it to a text widget.
                TextBoxField firstNField = new("FirstName");
                RectangleF firstNBounds = new(120, y - textHeight + 4, 220, textHeight);
                TextBoxWidgetAnnotation firstNWidget = new(firstNField, firstNBounds);
                firstNWidget.FontSize = 12;
                page.Annotations.Add(firstNWidget);
                y -= step;
    
                // Create a label for the last name field.
                TextFragment lastNLabel = new() {
                    Text = "Last name:",
                    Location = new PointF(50, y - textHeight / 2),
                    Font = textFont
                };
                page.Fragments.Add(lastNLabel);
    
                // Create the last name field and bind it to a text widget.
                TextBoxField lastNField = new("LastName");
                RectangleF lastNBounds = new(120, y - textHeight + 4, 220, textHeight);
                TextBoxWidgetAnnotation lastNWidget = new(lastNField, lastNBounds);
                lastNWidget.FontSize = 12;
                page.Annotations.Add(lastNWidget);
                y -= step;
    
                // Create a group field and add both text fields to the group.
                GroupField groupField = new GroupField("Group");
                groupField.Kids.Add(firstNField);
                groupField.Kids.Add(lastNField);
                pdfDocument.Fields.Add(groupField);
            }
        }
    }
    

    Implements

    Inheritance

    Object
    FormField
    GroupField
    See Also