Adds a field to a Fields collection.

Namespace:  C1.C1Report
Assembly:  C1.C1Report.2 (in C1.C1Report.2.dll)

Syntax

C#
public Field Add(
	string name,
	string text,
	double left,
	double top,
	double width,
	double height
)
Visual Basic
Public Function Add ( _
	name As String, _
	text As String, _
	left As Double, _
	top As Double, _
	width As Double, _
	height As Double _
) As Field

Parameters

name
Type: System..::..String
Contains the name of the new field. You should use a consistent naming scheme for the fields and avoid using duplicate names for report fields and database fields. Using repeated names is legal but will cause VBScript expressions that use repeated field names to yield unexpected results.
text
Type: System..::..String
Contains the value for the new field's Text property. This value may be treated as a literal or as a VBScript expression, depending on the setting of the field's Calculated property. By default, Calculated is set to false and the text is rendered as-is.
left
Type: System..::..Double
Left coordinate of the new field, in twips, with respect to its containing section.
top
Type: System..::..Double
Top coordinate of the new field, in twips, with respect to its containing section.
width
Type: System..::..Double
Width of the new field, in twips.
height
Type: System..::..Double
Height of the new field, in twips.

Return Value

A reference to the newly added field.

Remarks

If you add a field to a section's Fields collection, the new field is automatically assigned to that section.

If you add a field to the control's Fields collection, the new field is not assigned to any sections. In this case, you must set the field's Section property or it will not be rendered in the report.

Examples

The following code adds a new field to the report:

Copy CodeVisual Basic
c1r.Fields.Add("NewField", "Hello World", 100, 100, 2000, 300)
c1r.Fields("NewField").Section = SectionTypeEnum.Detail
Copy CodeC#
c1r.Fields.Add("NewField", "Hello World", 100, 100, 2000, 300);
c1r.Fields["NewField"].Section = SectionTypeEnum.Detail;

Alternatively, the above code could also be written as:

Copy CodeVisual Basic
Dim theField As Field
theField = c1r.Fields.Add("NewField", "Hello World", 100, 100, 2000, 300)
theField.Section = SectionTypeEnum.Detail
Copy CodeC#
Field theField;
theField = c1r.Fields.Add("NewField", "Hello World", 100, 100, 2000, 300);
theField.Section = SectionTypeEnum.Detail;

See Also