Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: How to access TextBox object using RAS Post Reply Post New Topic
Page  of 2 Next >>
Author Message
shortduck
Newbie
Newbie


Joined: 17 Mar 2009
Online Status: Offline
Posts: 13
Quote shortduck Replybullet Topic: How to access TextBox object using RAS
    Posted: 17 Mar 2009 at 7:10am
Hello

 we are displaying crystal reports using the RAS (Report Application Server). I was able to show the report, pupulating the details section using the dataset.

But I am unable to fingure out a way of accessing the TextBox object, so that I can change the static text in the report, e,g, Title of the report, Address of the client etc.

I guess I need some method/class put of ReportClientDocumentto access the objects.

 Any Idea?

thanks
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 17 Mar 2009 at 10:44am
I haven't tried this but I think it will work...
 
1. In your report, go to Format... for the text boxes that you want to format and give each of them a specific name.
 
2.  For each text box you want to update, get ReportClientDoc.ReportDefController.ReportDefinition.FindObjectByName and cast it as ISCRTextObject and use the Text property to upate the text.
 
-Dell
IP IP Logged
shortduck
Newbie
Newbie


Joined: 17 Mar 2009
Online Status: Offline
Posts: 13
Quote shortduck Replybullet Posted: 17 Mar 2009 at 10:58am
Hi Dell
 
Many thanks for your response.
 
this is what I am using:

TextObjectClass objs = rptClientDoc.ReportDefController.ReportDefinition.FindObjectByName("txtProviderName") as TextObjectClass;

objs.Text = "Hello";
 
I am getting null for the objs  and also the Text property is "read-only".
 
any other idea?
 
Short Duck
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 17 Mar 2009 at 12:52pm

Don't use TextObjectClass, use ISCRTextObject.  The SDK can be picky about whether you use the class or the interface and the documentation recommends that you use the interface.

The documentation says that the Text property "Gets and Sets" the value, so the "read only" is probably a function of the fact that the object is null.
 
-Dell
IP IP Logged
shortduck
Newbie
Newbie


Joined: 17 Mar 2009
Online Status: Offline
Posts: 13
Quote shortduck Replybullet Posted: 17 Mar 2009 at 1:24pm

objs.Text = "Hello";

give compilation error, says the the Text is a read only properly. Also
 
But :) hurray, now atleast I am able o get the reference with this:
 

ISCRTextObject objs = rptClientDoc.ReportDefController.ReportDefinition.FindObjectByName("txtProviderName") as ISCRTextObject;

Now I need to figure out a way through which I can change the text of this Textbox Object.

Please stay with me.
thanks
Duck
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 17 Mar 2009 at 1:36pm
Try going through the Paragraphs property instead of the Text property.  Use ISCRParagraphs instead of ISCRTextObject.  You'll have to dig down to the ISCRParagraphElement level - create a new element of typ crParagraphElementKindText and add it to a new ISCRParagraph object.  In your ISCRParagraphs object, do a RemoveAll() and then Add the new ISCRParagraph object.
 
It looks pretty complicated but it's the only possible way I see around the readonly Text issue.
 
-Dell
IP IP Logged
shortduck
Newbie
Newbie


Joined: 17 Mar 2009
Online Status: Offline
Posts: 13
Quote shortduck Replybullet Posted: 17 Mar 2009 at 2:01pm
I am leaving for the day, I'll try this first thing in the morning and will post the results.
 
thanks anyways,
IP IP Logged
shortduck
Newbie
Newbie


Joined: 17 Mar 2009
Online Status: Offline
Posts: 13
Quote shortduck Replybullet Posted: 18 Mar 2009 at 7:24am
Hi
 
As suggested I am using the following code:
 
The code do not give any error, but it does not seems to work either. I can not see text "Hello" on the report.

ISCRTextObject objs = rptClientDoc.ReportDefController.ReportDefinition.FindObjectByName("txtProviderName") as ISCRTextObject;

objs.Paragraphs.RemoveAll();

Paragraph objParagraph = new Paragraph();

ParagraphTextElement element = new ParagraphTextElement();

objParagraph.Alignment = CrAlignmentEnum.crAlignmentLeft;

element.Text = "Hello";

objParagraph.ParagraphElements.Add(element);

objs.Paragraphs.Add(objParagraph);

 
Is there anything that I am missing.
 
Short
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 18 Mar 2009 at 9:23am

Here again, try using the interfaces:  ISCRParagrah and ISCRParagraphElement.

-Dell
IP IP Logged
shortduck
Newbie
Newbie


Joined: 17 Mar 2009
Online Status: Offline
Posts: 13
Quote shortduck Replybullet Posted: 18 Mar 2009 at 10:20am
Hi
 
I used the following code and was able to show Text on the crystal report.
 

CrystalDecisions.ReportAppServer.ReportDefModel.FontColor boFontColor;

CrystalDecisions.ReportAppServer.ReportDefModel.Font boFont;

CrystalDecisions.ReportAppServer.ReportDefModel.TextObject objs;

objs = new CrystalDecisions.ReportAppServer.ReportDefModel.TextObject();

Paragraph objParagraph = new Paragraph();

Paragraphs objParagraphs = new Paragraphs();

ParagraphTextElement element = new ParagraphTextElement();

CrystalDecisions.ReportAppServer.ReportDefModel.ParagraphElements elements = new CrystalDecisions.ReportAppServer.ReportDefModel.ParagraphElements();

objParagraph.Alignment = CrAlignmentEnum.crAlignmentLeft;

element.Text = "Hello";

element.Kind = CrystalDecisions.ReportAppServer.ReportDefModel.CrParagraphElementKindEnum.crParagraphElementKindText;

boFontColor = new CrystalDecisions.ReportAppServer.ReportDefModel.FontColor();

boFont = new CrystalDecisions.ReportAppServer.ReportDefModel.Font();

boFont.Bold = false;

boFont.Name = "Arial";

boFontColor.Font = boFont;

element.FontColor = boFontColor;

elements.Add(element);

objParagraph.ParagraphElements = elements;

objParagraphs.Add(objParagraph);

objs.Paragraphs = objParagraphs;

objs.Left = 86;

objs.Top = 1118;

objs.Width = 4644;

objs.Height = 221;

rptClientDoc.ReportDefController.ReportObjectController.Add(objs, rptClientDoc.ReportDefController.ReportDefinition.DetailArea.Sections[0], -1);

The only thing is that I am using a new TextObject. This code do not works if I have the reference of the existing textObject.

anyways, I guess its too long and complicated to just set a small label on the Crystal Report.
 
I will have to find some other way to doing the task.
 
Thanks much Dell for your time.
 
Short.
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.