Set Panel.Enabled via DataBand.BeforePrintEvent.Script
Posted: Wed May 30, 2012 9:26 am
Hi, I am creating a label report via code and want to hide the label container panel based on the value of a variable. But it does not work and the panel always shows when the report is displayed in either the Silverlight viewer or designer/preview. If I save the report and then load in the stand-alone designer it works and the first 4 labels are hidden. Below is part of the code I am using, and I have attached the saved report:
StiDataBand objDataBand = new StiDataBand();
objDataBand.Height = LabelDefinition.Style.LabelStyle_LabelPitchVertical;
objDataBand.Name = "DataBand";
objDataBand.BusinessObjectGuid = ReportDefinition.Dictionary.BusinessObjects[0].Guid;
objDataBand.Columns = intCols;
objDataBand.ColumnWidth = LabelDefinition.Style.LabelStyle_LabelWidth;
objDataBand.ColumnDirection = StiColumnDirection.AcrossThenDown;
objDataBand.ColumnGaps = LabelDefinition.Style.LabelStyle_LabelPitchHorizonal - LabelDefinition.Style.LabelStyle_LabelWidth;
objReportPage.Components.Add(objDataBand);
StiPanel objLabelArea = new StiPanel(new RectangleD(0,0,LabelDefinition.Style.LabelStyle_LabelWidth,LabelDefinition.Style.LabelStyle_LabelHeight));
objLabelArea.Name = "LabelArea";
objDataBand.Components.Add(objLabelArea);
objDataBand.BeforePrintEvent.Script = "LabelArea.Enabled = (StartLabel <= 0)";
objDataBand.AfterPrintEvent.Script = "StartLabel--";
I have also tried enclosing StartLabel in {} but that did not work either.
I would be grateful for you could tell me what I am doing wrong?
StiDataBand objDataBand = new StiDataBand();
objDataBand.Height = LabelDefinition.Style.LabelStyle_LabelPitchVertical;
objDataBand.Name = "DataBand";
objDataBand.BusinessObjectGuid = ReportDefinition.Dictionary.BusinessObjects[0].Guid;
objDataBand.Columns = intCols;
objDataBand.ColumnWidth = LabelDefinition.Style.LabelStyle_LabelWidth;
objDataBand.ColumnDirection = StiColumnDirection.AcrossThenDown;
objDataBand.ColumnGaps = LabelDefinition.Style.LabelStyle_LabelPitchHorizonal - LabelDefinition.Style.LabelStyle_LabelWidth;
objReportPage.Components.Add(objDataBand);
StiPanel objLabelArea = new StiPanel(new RectangleD(0,0,LabelDefinition.Style.LabelStyle_LabelWidth,LabelDefinition.Style.LabelStyle_LabelHeight));
objLabelArea.Name = "LabelArea";
objDataBand.Components.Add(objLabelArea);
objDataBand.BeforePrintEvent.Script = "LabelArea.Enabled = (StartLabel <= 0)";
objDataBand.AfterPrintEvent.Script = "StartLabel--";
I have also tried enclosing StartLabel in {} but that did not work either.
I would be grateful for you could tell me what I am doing wrong?