我正在telerik报告中动态创建表的列。 这是代码:
//create two HtmlTextBox items (one for header and one for data) which would be added to the items collection of the table
Telerik.Reporting.HtmlTextBox textboxGroup;
Telerik.Reporting.HtmlTextBox textBoxTable;
//we do not clear the Rows collection, since we have a details row group and need to create columns only
this.table1.ColumnGroups.Clear();
this.table1.Body.Columns.Clear();
this.table1.Body.Rows.Clear();
int i = 0;
this.table1.ColumnHeadersPrintOnEveryPage = true;
var attributes = _objectInstances.First().ObjectType.Attributes;
foreach (var attribute in attributes)
{
if (string.IsNullOrWhiteSpace(attribute.ColumnName) || !_objectInstances.First().Dictionary.ContainsKey(attribute.ColumnName)) continue;
var tableGroupColumn = new Telerik.Reporting.TableGroup();
this.table1.ColumnGroups.Add(tableGroupColumn);
this.table1.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Unit.Inch(1)));
textboxGroup = new Telerik.Reporting.HtmlTextBox();
textboxGroup.Style.BorderColor.Default = Color.Black;
textboxGroup.Style.BorderStyle.Default = BorderType.Solid;
textboxGroup.Value = attribute.ColumnName;
textboxGroup.Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
tableGroupColumn.ReportItem = textboxGroup;
textBoxTable = new Telerik.Reporting.HtmlTextBox();
textBoxTable.Style.BorderColor.Default = Color.Black;
textBoxTable.Style.BorderStyle.Default = BorderType.Solid;
textBoxTable.Value = "=Fields." + attribute.ColumnName;
textBoxTable.Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
this.table1.Body.SetCellContent(0, i++, textBoxTable);
this.table1.Items.AddRange(new ReportItemBase[] {textBoxTable, textboxGroup});
}
这个问题是列宽是固定的。 如果我尝试使用textbox.Dock = DockStyle.Fill; 我得到一个对象引用错误。 有没有办法根据内容自动调整列宽?
答案 0 :(得分:0)
<h1 id="title">Array operations with random functions & Big o notation Analysis</h1>
Enter an element to search(1-100):
<input type="text" id="myTextField1"/>
<input type="submit" id="byBtn" value="SearchArray" onclick="StoreArray()"/> <br>
Number of comparisions:<input type="text" id="myTextField2"/>