【发布时间】:2014-04-07 21:23:29
【问题描述】:
我目前正在使用 Telerik Reporting(2013 年第一季度发布)编写报告,我正在尝试在运行时将文本框添加到标题(最终也是详细信息部分),但问题是文本框添加的内容不显示。我不确定它为什么不显示,但添加后没有出现错误。现在我正在尝试在 itemdatabinding 事件期间添加它。我的代码如下:
public partial class _WellPlateReport : Telerik.Reporting.Report
{
public _WellPlateReport(Dictionary<string, object> ReportParameters)
{
//
// Required for telerik Reporting designer support
//
InitializeComponent();
tbGenotype.Visible = false;
//
// TODO: Add any constructor code after InitializeComponent call
//
}
private void labelsGroupHeaderSection_ItemDataBinding(object sender, EventArgs e)
{
string temp = "";
Telerik.Reporting.Processing.GroupSection headerGroup = (Telerik.Reporting.Processing.GroupSection)sender;
Telerik.Reporting.TextBox tb = new Telerik.Reporting.TextBox();
tb.Left = new Telerik.Reporting.Drawing.Unit(0.5, UnitType.Inch) + tbGenotype.Left + tbGenotype.Width;
//tb.Width = new Telerik.Reporting.Drawing.Unit(3.0, UnitType.Inch);
tb.Size = tbSex.Size;
tb.Name = "TestLabel1";
tb.Value = "Test Label";
tb.Location = new Telerik.Reporting.Drawing.PointU(tbGenotype.Left + tbGenotype.Width + new Telerik.Reporting.Drawing.Unit(0.5, UnitType.Inch), Telerik.Reporting.Drawing.Unit.Inch(0D));
//this.labelsGroupHeaderSection.Items.Add(tb);
//this.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { tb });
this.labelsGroupHeaderSection.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { tb });
}
}
tbGenotype 是另一个文本框,新文本框将在运行时添加到旁边,所以我使用它的定位来放置动态文本框。需要添加未知数量的附加列,但我不确定为什么这不起作用。我的搜索显示其他人以类似的方式添加控件。
更新:另请注意,文本框 tbGenotype 已添加到 Visual Studio 的设计器中。尝试在其上设置可见属性,但将文本框添加到标题中不起作用。
【问题讨论】:
标签: c# asp.net-mvc-4 dynamic runtime telerik-reporting