TextObject.ApplyFont Method
Applies changes made to the System.Drawing.Font object.
Namespace CrystalDecisions.CrystalReports.Engine Assembly CrystalDecisions.CrystalReports.Engine (CrystalDecisions.CrystalReports.Engine.dll)
Syntax
'Declaration
Public Overrideable Sub ApplyFont ( _
ByVal font As System.Drawing.Font _
)
public virtual void ApplyFont (
System.Drawing.Font font
)
Parameters
- font
Contains the font settings for the TextObject.
Example
This example sets the font and color of a TextObject. The method gets the ReportObject by name from the ReportObjects collection and casts it as a TextObject. The method then applies the settings from the font dialog to the TextObject, and sets the color of the TextObject to blue.
'Declaration
Public Sub SetFont(ByVal reportObjectName As String)
Dim text As TextObject
Dim fieldFont As New FontDialog()
If TypeOf _
(Report.ReportDefinition.ReportObjects. _
Item(reportObjectName)) Is TextObject Then
text = _
Report.ReportDefinition.ReportObjects. _
Item(reportObjectName)
If fieldFont.ShowDialog() = DialogResult.OK Then
text.ApplyFont(fieldFont.Font)
text.Color = Color.Blue
End If
End If
private void SetFont(string reportObjectName)
{
TextObject text;
FontDialog fieldFont = new FontDialog();
text = Report.ReportDefinition.ReportObjects[reportObjectName]
as TextObject;
if (text!= null)
{
if (fieldFont.ShowDialog() == DialogResult.OK)
{
text.ApplyFont(fieldFont.Font);
text.Color = Color.Blue;
}
}
}
Version Information
Crystal Reports Basic for Visual Studio 2008
Supported since: Crystal Reports for Visual Studio .NET 2002
See Also
Reference
TextObject Class
TextObject Members
CrystalDecisions.CrystalReports.Engine Namespace