Crystal Report: Format Horizontal Alignment

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
 
J

Jorge

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
 
B

blackdevil1979

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top