Hi all,
My DataSource looks like:
...and as you can see I'm binding it to the report at the NeedDataSource Event.
I'm facing a huge difficulty trying to get a Report formatting certain items at ItemDataBinding.
My idea would be to build a "general purpose" report able to show informations from a DataSource and displaying each item of those datas in tow possible different ways:
- As a Label + TextBox
- As a Label + CheckBox
| Private Sub Report_NeedDataSource(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.NeedDataSource |
| Dim oRowList As New List(Of MyDataRow) |
| oRowList.Add(New MyDataRow("Sezione 1", 1, "Nome del candidato", "Mario")) |
| oRowList.Add(New MyDataRow("Sezione 1", 1, "Cognome del candidato", "Rossi")) |
| oRowList.Add(New MyDataRow("Sezione 1", 1, "Data di nascita", "20/05/1960")) |
| oRowList.Add(New MyDataRow("Sezione 2", 1, "Indirizzo", "Via Milano, 18")) |
| oRowList.Add(New MyDataRow("Sezione 2", 1, "Cap", "20100")) |
| oRowList.Add(New MyDataRow("Sezione 2", 1, "Città ", "Milano")) |
| oRowList.Add(New MyDataRow("Sezione 2", 1, "Provincia", "MI")) |
| oRowList.Add(New MyDataRow("Sezione 3", 1, "Animale preferito", "")) |
| oRowList.Add(New MyDataRow("Sezione 3", 2, "Gatto", "X")) |
| oRowList.Add(New MyDataRow("Sezione 3", 2, "Cane", "")) |
| oRowList.Add(New MyDataRow("Sezione 3", 2, "Pappagallo", "X")) |
| CType(sender, Telerik.Reporting.Processing.Report).DataSource = oRowList |
| End Sub |
The Class MyDataRow contains:
- Group Field
- Type field
- Label field
- Text field
My Report Contains a Grouping, based on the "Group" field, and two TextBox bounded to the Label field and to the Text field of my MyDataRow. If I run the Report I can see all my datas correctly bounded.
The problem raises when I try to intervene on formatting of the two TextBox fields at DataBinding. Code follows:
| Private Sub DetailSection1_ItemDataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailSection1.ItemDataBinding |
| Dim ProcessingDetail As Telerik.Reporting.Processing.DetailSection = CType(sender, Telerik.Reporting.Processing.DetailSection) |
| Dim oDataRow As MyDataRow = CType(ProcessingDetail.DataObject.RawData, MyDataRow) |
| If oDataRow.Type = 2 Then |
| T_Label.Size = New SizeU(New Unit(18, UnitType.Cm), New Unit(0.5, UnitType.Cm)) |
| T_Label.Location = New PointU(New Unit(1, UnitType.Cm), New Unit(0, UnitType.Cm)) |
| T_Text.Style.BorderColor.Default = Color.Black |
| T_Text.Style.BorderStyle.Default = BorderType.Solid |
| T_Text.Style.BorderWidth.Default = New Unit(2, UnitType.Point) |
| T_Text.Size = New SizeU(New Unit(0.5, UnitType.Cm), New Unit(0.5, UnitType.Cm)) |
| T_Text.Location = New PointU(New Unit(0, UnitType.Cm), New Unit(0, UnitType.Cm)) |
| T_Text.Style.TextAlign = HorizontalAlign.Center |
| T_Text.Style.Font.Bold = True |
| End If |
| End Sub |
As you ca see, if the Type field of my Datasource is "2" what I do is format my two TextBoxes in such a way that they look like a CheckBox and a label following. HERE RAISES THE PROBLEM !
What comes out of my report is that the formatting gets applied only after the first "Record" of my data source has been parsed. Attached You'll find a screen shot of what happens when I get to bind the part of the data source containing Records of type "2".
I'm relatively new to programming and especially with Telerik components, so I might have posted a "stupid" problem, but I'm going nuts.
Thanks for any help provided.
Lorenzo