We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to Read docx

Hi, I am new to using Aspose. Could you please provide a sample to read checkbox, combo box, dropdown and textbox created in docx

@Ap466,

Thanks for your inquiry. Following code example shows how to insert and read the form fields of document. Hope this helps you.

DocumentBuilder builder = new DocumentBuilder();

// Insert a text form field for input a name.
builder.InsertTextInput("", TextFormFieldType.Regular, "", "Enter your name here", 30);

// Insert two blank lines.
builder.Writeln("");
builder.Writeln("");

string[] items = new string[]
    {
"-- Select your favorite footwear --",
"Sneakers",
"Oxfords",
"Flip-flops",
"Other",
"I prefer to be barefoot"
    };

// Insert a combo box to select a footwear type.
builder.InsertComboBox("", items, 0);

// Insert 2 blank lines.
builder.Writeln("");
builder.Writeln("");

// Insert a check box to ensure the form filler does look after his/her footwear.
builder.InsertCheckBox("", true, 0);
builder.Writeln("My boots are always polished and nice-looking.");
                  
builder.Document.Save(MyDir + "DocumentBuilder.CreateForm Out.doc");


Document doc = new Document(MyDir + "DocumentBuilder.CreateForm Out.doc");

foreach (FormField field in doc.Range.FormFields)
{
    if (field.Type == FieldType.FieldFormCheckBox)
        field.Checked = true;

    if (field.Type == FieldType.FieldFormDropDown)
        field.DropDownSelectedIndex = 2;

    if (field.Type == FieldType.FieldFormTextInput)
        field.SetTextInputValue("Aspose.Words");
}
doc.Save(MyDir + "output.docx");