Creating a Form with Table
Our sample projects and report templates can help you learn the basics of working with our products.This example is outdated, you can check out the many other new examples in this category.This example shows how to create a form with table.
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.Right
});
for (var i = 1; i <= 10; i++)
table.RowsCollection.Labels.Add(i.ToString());
table.RowsCollection.Width = 20;
table.RowsCollection.Alignment = StiHorizontalAlignment.Center;
table.TotalsRow.Fields.Add(new StiTotalsFieldItem()
{
Header = "Total",
Prefix = "$",
Expression = "{Sum(Col(6))}"
});
page.Elements.Add(table);
var button = new StiButtonElement()
{
ButtonType = StiButtonType.SendForm,
Geometry = new StiRectangleGeometry(page.ContentAreaWidth / 2 - 200, 700, 400, 100)
};
button.Text.Value = "Submit";
page.Elements.Add(button);
return form;
}