Hi,
I want add textbox in header group in runtime, what wrong in my code?
My Function that generate the textbox colection
The problem is that on runtime its don´t render the controls.How can I do it?
If I use this
What data type my function need return, or how can I make a foreach loop whit an Telerik.Reporting.ReportItemBase array.
Thanks
I want add textbox in header group in runtime, what wrong in my code?
private void gp_instrutor_header_ItemDataBinding(object sender, EventArgs e) | |
{ | |
Telerik.Reporting.Processing.GroupSection groupb = (Telerik.Reporting.Processing.GroupSection)sender; | |
try | |
{ | |
if (!dsSourceReport.Equals(null)) | |
{ | |
gp_instrutor_header.Items.AddRange(Report_Functions.clsReportFunctions.AdicionaTextBoxDinamico(dsSourceReport, "INSTRUTOR", "DS_GRUPO_QUESTAO", "VL_MEDIA", double.Parse("3,2"), double.Parse("0,4"), double.Parse("9,5"), double.Parse("0,85"), double.Parse("0,2"), double.Parse("0,1"))); | |
} | |
} | |
catch { } | |
} |
My Function that generate the textbox colection
public static ReportItemBase[] AdicionaTextBoxDinamico(DataSet dsReportSource, string _strPrefixo, string _strTermoDescricao, string _strTermoValor, double _dblTamX, double _dblTamY, double _dblPosInicialX, double _dblPosInicialY, double _dblEspassamentoHorizontal, double _dblEspassamentoVertical) | |
{ | |
try | |
{ | |
#region Determinar a quantidade de colunas dinâmicas | |
int _intNumeroColunas = 0; | |
foreach (DataColumn coluna in dsReportSource.Tables[0].Columns) | |
{ | |
if (coluna.ColumnName.StartsWith(_strPrefixo)) | |
{ | |
_intNumeroColunas++; | |
} | |
} | |
_intNumeroColunas = _intNumeroColunas / 2; | |
#endregion | |
#region Monta Objetos(TextBox) que serão inseridos no relatório | |
TextBox txtDynamicColumnDescription; | |
TextBox txtDynamicColumnValue; | |
List lstControls = new List(); | |
for (int i = 1; i <= _intNumeroColunas; i++) | |
{ | |
if (!_strTermoDescricao.Equals("")) | |
{ | |
#region Controle de Descrição (titulo do valor) | |
txtDynamicColumnDescription = new TextBox(); | |
txtDynamicColumnDescription.Name = _strPrefixo + "_" + _strTermoDescricao + "_" + i.ToString(); //ex.: curso_questao_1 | |
txtDynamicColumnDescription.Value = "=Fields." + _strPrefixo + "_" + _strTermoDescricao + "_" + i.ToString(); | |
txtDynamicColumnDescription.Size = new SizeU(new Unit(_dblTamX, UnitType.Cm), new Unit(_dblTamY, UnitType.Cm)); | |
txtDynamicColumnDescription.Style.Color = System.Drawing.Color.Black; | |
txtDynamicColumnDescription.Style.Font.Bold = true; | |
txtDynamicColumnDescription.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(7, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Point))); | |
txtDynamicColumnDescription.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; | |
txtDynamicColumnDescription.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; | |
if (i == 1) | |
{ | |
txtDynamicColumnDescription.Location = new PointU(new Unit(_dblPosInicialX, UnitType.Cm), new Unit(_dblPosInicialY, UnitType.Cm)); | |
} | |
else | |
{ | |
double _dblX, _dblY; | |
///Posição Inicial + espaçamento horizontal + tamanho do controle | |
_dblX = ((_dblPosInicialX + _dblEspassamentoHorizontal) + (_dblTamX * (double.Parse(i.ToString()) - 1))); | |
///Mantém-se fixo, não variavél | |
_dblY = _dblPosInicialY; | |
txtDynamicColumnDescription.Location = new PointU(new Unit(_dblX, UnitType.Cm), new Unit(_dblY, UnitType.Cm)); | |
} | |
#endregion | |
#region Adiciona Controles de Descrição no Array | |
lstControls.Items.Add(txtDynamicColumnDescription); | |
#endregion | |
} | |
if (!_strTermoValor.Equals("")) | |
{ | |
#region Controle de Valores (Valores) | |
txtDynamicColumnValue = new TextBox(); | |
txtDynamicColumnValue.Name = _strPrefixo + "_" + _strTermoValor + "_" + i.ToString(); //ex.: curso_questao_1 | |
txtDynamicColumnValue.Value = "=Fields." + _strPrefixo + "_" + _strTermoValor + "_" + i.ToString(); | |
txtDynamicColumnValue.Size = new SizeU(new Unit(_dblTamX, UnitType.Cm), new Unit(_dblTamY, UnitType.Cm)); | |
txtDynamicColumnValue.Style.Color = System.Drawing.Color.Blue; | |
txtDynamicColumnValue.Style.Font.Bold = true; | |
txtDynamicColumnValue.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(7, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Point))); | |
txtDynamicColumnValue.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; | |
txtDynamicColumnValue.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; | |
if (i == 1) | |
{ | |
double _dblY; | |
///Posição Inicial + espaçamento vertical + tamanho do controle | |
_dblY = (_dblPosInicialY + _dblEspassamentoVertical + _dblTamY); | |
txtDynamicColumnValue.Location = new PointU(new Unit(_dblPosInicialX, UnitType.Cm), new Unit(_dblY, UnitType.Cm)); | |
} | |
else | |
{ | |
double _dblX, _dblY; | |
///Posição Inicial + espaçamento horizontal + tamanho do controle | |
_dblX = ((_dblPosInicialX + _dblEspassamentoHorizontal) + (_dblTamX * (double.Parse(i.ToString()) - 1))); | |
///Posição Inicial + espaçamento vertical + tamanho do controle | |
_dblY = (_dblPosInicialY + _dblEspassamentoVertical + _dblTamY); | |
txtDynamicColumnValue.Location = new PointU(new Unit(_dblX, UnitType.Cm), new Unit(_dblY, UnitType.Cm)); | |
} | |
#endregion | |
#region Adiciona Controles de Valor no Array | |
lstControls.Items.Add(txtDynamicColumnValue); | |
#endregion | |
} | |
} | |
#endregion | |
#region Array com todos os controles | |
ReportItemBase[] reportControls = new ReportItemBase[lstControls.Items.Count]; | |
for (int i = 0; i < lstControls.Items.Count; i++) | |
{ | |
reportControls[i] = lstControls.Items[i]; | |
} | |
#endregion | |
return reportControls; | |
} | |
catch (Exception error) | |
{ | |
///Lança a exeção gerada pelo método e retorna nulo; | |
throw new Exception(error.Message.ToString()); | |
return null; | |
} | |
} |
The problem is that on runtime its don´t render the controls.How can I do it?
If I use this
Telerik.Reporting.Processing.GroupSection groupb = (Telerik.Reporting.Processing.GroupSection)sender; | |
groupb.Items.Add(item); |
What data type my function need return, or how can I make a foreach loop whit an Telerik.Reporting.ReportItemBase array.
Thanks