Crystal Report: Format Horizontal Alignment

  • Thread starter Thread starter blackdevil1979
  • Start date Start date
B

blackdevil1979

Hello,

Is there a way to format the data when it is passed into the Crystal
Report(CR).. for example.. In the original table, a number may be
left aligned, how to change it to right alignment?.. in other words I
want to change it's Format: Horizontal Alignment
from Left To Right if the
data passed in is an Integer, Currency, or
DateTime.

thanx
 
Hi BlackDevil,

This is how i do it :

Dim crreportobject As
CrystalDecisions.CrystalReports.Engine.ReportObject

For Each crreportobject In
crReportDocument.ReportDefinition.ReportObjects
'' formats text object
If TypeOf (crreportobject) Is
CrystalDecisions.CrystalReports.Engine.TextObject Then
Dim crtextobject As
CrystalDecisions.CrystalReports.Engine.TextObject
If Trim(crreportobject.Name) = "Text2" Then
crtextobject = DirectCast(crreportobject,
CrystalDecisions.CrystalReports.Engine.TextObject)
crtextobject.Text = "Hi"
End If
End If
'' formats field object
If TypeOf (crreportobject) Is
CrystalDecisions.CrystalReports.Engine.FieldObject Then
Dim crtextobject As
CrystalDecisions.CrystalReports.Engine.FieldObject
If Trim(crreportobject.Name) = "Field73" Then
crtextobject = DirectCast(crreportobject,
CrystalDecisions.CrystalReports.Engine.FieldObject)

crtextobject.ObjectFormat.HorizontalAlignment =
Alignment.RightAlign
End If
End If


Next

Kind Regards
Jorge
 
Hello Jorge,

Sorry, need to ask you something.

1. What crReportDocument? Is it the name of your Crystal Report or
something else?

a)........because when I change from
crReportDocument.ReportDefinition.ReportObjects()
to
[b:ba3448b144]report[/b:ba3448b144].ReportDefinition.ReportObjects()
(dim Public report As CrystalReport1 = New CrystalReport1) it there
are some incorrect syntax such as with
crreportobject.Name,
[i:ba3448b144]DirectCast(crreportobject,
CrystalDecisions.CrystalReports.Engine.TextObject) [/i:ba3448b144],
and [i:ba3448b144]crtextobject.Text[/i:ba3448b144],
[i:ba3448b144]crtextobject.ObjectFormat[/i:ba3448b144],
[i:ba3448b144]Alignment.RightAlign().[/i:ba3448b144]

b) if i dont change it, [b:ba3448b144]crReportDocument[/b:ba3448b144]
needs declaration..and
[i:ba3448b144]crtextobject.Text[/i:ba3448b144],
[i:ba3448b144]crtextobject.ObjectFormat[/i:ba3448b144],
[i:ba3448b144]Alignment.RightAlign().[/i:ba3448b144] and
[i:ba3448b144]DirectCast(crreportobject,
CrystalDecisions.CrystalReports.Engine.FieldObject)[/i:ba3448b144]
has syntax error.

c) If I change it to
[b:ba3448b144]OrrasReport.[/b:ba3448b144]ReportDefinition , it stated
that reference to non-shared member requires an object reference. and
the same other syntax error in b).

thanks
 
Back
Top