ComponentOne Reports for WinForms Designer Edition: ComponentOne Reports for WinForms > Working with C1PrintDocument > Data Binding > Data Binding in Render Objects

Data Binding in Render Objects

When a render object is created, the data binding for it is not created initially. It is created when the DataBinding property is referenced in user code. For example:

      Visual Basic

Dim rt As RenderText = New RenderText

' ...

If Not (rt.DataBinding Is Nothing) Then

    MessageBox.Show("Data binding defined.")

End If

      C#

RenderText rt = new RenderText();

// ...

if (rt.DataBinding != null)

{

    MessageBox.Show("Data binding defined.");

}

The condition in the previous code will always evaluate to True. Thus if you only want to check whether data binding exists on a particular render object, you should use the DataBindingDefined property instead:

      Visual Basic

Dim rt As RenderText = New RenderText

' ...

If rt.DataBindingDefined Then

    MessageBox.Show("Data binding defined.")

End If

      C#

RenderText rt = new RenderText();

// ...

if  (rt.DataBindingDefined)

{

    MessageBox.Show("Data binding defined.");

}

Note: This is similar to the Handle and IsHandleCreated properties of the WinForms Control class.

During document generation the RenderObjectsList collection is formed. Three different situations are possible as a result:

      The Copies property on the render object is null. This means that the object is not data bound, and is processed as usual. The Fragments property of the object can be used to access the actual rendered fragments of the object on the generated pages.

      The Copies property on the render object is not null, but Copies.Count is 0. This means that the object is data bound, but the data set is empty (contains no records). In such situations the object is not show in the document at all, that is, no fragments are generated for the object. For an example see Binding to the Empty List in the DataBinding sample.

      The Copies property on the render object is not null and Copies.Count is greater than 0. This means that the object is data bound, and the data source is not empty (contains records). During the document generation, several copies of the render object will be created and placed in this collection. Those copies will then be processed and fragments will be generated for each copy as usual.


Data bound tables


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.