Assembly: C1.Win.C1ReportDesigner.2 (in C1.Win.C1ReportDesigner.2.dll)
Syntax
C# |
---|
[BrowsableAttribute(false)] [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)] public Object CreateFieldInfo { get; set; } |
Visual Basic |
---|
<BrowsableAttribute(False)> _ <DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)> _ Public Property CreateFieldInfo As Object Get Set |
Remarks
When you set this property to a non-null value, the designer assumes you want to create a new field. It will change the mouse cursor into a cross-hair and will allow the user to mark the position of the new field on the report.
When the user concludes the mouse operation, the control fires the CreateField event. At this point, the event handler can refer to the CreateInfo property and use the information in the event parameters to create a new field and initialize it.
Examples
The C1ReportDesigner application has a toolbar that is used for creating new fields. The toolbar contains buttons for several different types of fields.
When a button is clicked, the application stores a reference to the button that was clicked in the CreateFieldInfo property and waits for the CreateField event. When the user moves the mouse over the designer, the cursor changes into a crosshair to indicate to the user that he can mark the location for the new field.
When the user is done marking the location of the new field, the control fires the CreateField event and the application uses the information in the event parameters to create the field.
Here is a simplified version of the code in the C1ReportDesigner:
private void _tbCreate_ButtonClick(object sender, ToolBarButtonClickEventArgs e) { // save type of field to create and wait for the CreateField event _designer.CreateFieldInfo = e.Button; } // user is creating a field with the mouse // (in response to setting the _designer.CreateFieldInfo property) private void _designer_CreateField(object sender, CreateFieldEventArgs e) { // save undo info _designer.UndoStack.SaveState(); // create new field in this section string fldName = GetUniqueFieldName(); FieldCollection fields = e.Section.Fields; Field field = fields.Add(fldName, null, e.FieldBounds); // set new field properties based on CreateFieldInfo object btn = e.CreateFieldInfo; if (btn == _btnLabel) { field.Text = field.Name; field.Calculated = false; } else if (btn == _btnPageBreak) { field.ForcePageBreak = ForcePageBreakEnum.After; field.Calculated = false; } else if (btn == _btnRectangle) { field.BorderStyle = BorderStyleEnum.Solid; field.Calculated = false; } else { Debug.Assert(false, "Unknown field creator object"); } // reset creator, select the new field _designer.CreateFieldInfo = null; _designer.SelectedFields = new Field[] { field }; } |