Creating a Form with Table
Our sample projects and report templates can help you learn the basics of working with our products.Build a PDF form in code, add a table with several column types, and prepare it for browser input.
Defining the table. The example creates the form and page first, then adds a table whose columns use text, combo-box, and numeric editors.
Column setup. The builder in
Ready for input. Because the complete definition is created in code, the same structure can be adjusted from application data before it reaches the browser.
Defining the table. The example creates the form and page first, then adds a table whose columns use text, combo-box, and numeric editors.
Column setup. The builder in
Creating a Form with Table/Controllers/FormsController.cs configures captions, widths, selectable values, and totals before the table is added to the page:private StiForm CreateForm()
{
var form = new StiForm();
var page = new StiFormPage();
form.Pages.Add(page);
var label = new StiLabelElement()
{
Geometry = new StiRectangleGeometry(0, 0, page.ContentAreaWidth, 200)
};
label.Text.Expression = "Custom Order Form";
label.Text.Font = new System.Drawing.Font("Segoe UI", 44, System.Drawing.FontStyle.Bold);
label.Text.HorizontalAlignment = StiHorizontalAlignment.Center;
page.Elements.Add(label);
var table = new StiTableElement()
{
Geometry = new StiRectangleGeometry(0, 200, page.ContentAreaWidth, 500),
Padding = new StiPadding(0)
};
table.Columns.Add(new StiTextBoxColumnItem()
{
Label = "ITEM",
HeaderAlignment = StiHorizontalAlignment.Center,
});
var sizeItem = new StiComboBoxColumnItem()
{
Label = "SIZE",
HeaderAlignment = StiHorizontalAlignment.Center,
};
sizeItem.ComboBoxOptions.Add("S");
sizeItem.ComboBoxOptions.Add("M");
sizeItem.ComboBoxOptions.Add("L");
table.Columns.Add(sizeItem);
table.Columns.Add(new StiTextBoxColumnItem()
{
Label = "COLOR",
HeaderAlignment = StiHorizontalAlignment.Center,
});
table.Columns.Add(new StiNumberBoxColumnItem()
{
Label = "QTY",
HeaderAlignment = StiHorizontalAlignment.Center,
DecimalDigits = 0,
Width = 30,
});
table.Columns.Add(new StiNumberBoxColumnItem()
{
Label = "PRCE",
HeaderAlignment = StiHorizontalAlignment.Center,
Width = 60,
UnitLabel = "$",
UnitAlignment = StiUnitAlignment.PrefixInside
});
table.Columns.Add(new StiLabelColumnItem()
{
Label = "Total",
HeaderAlignment = StiHorizontalAlignment.Center,
Expression = "{Col(4) * Col(5)}",
Prefix = "$",
CellAlignment = StiHorizontalAlignment.RightReady for input. Because the complete definition is created in code, the same structure can be adjusted from application data before it reaches the browser.