Author |
Message |
shortduck
Newbie
Joined: 17 Mar 2009
Online Status: Offline
Posts: 13
|
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 Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|
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 Logged |
|
shortduck
Newbie
Joined: 17 Mar 2009
Online Status: Offline
Posts: 13
|
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 Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|
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 Logged |
|
shortduck
Newbie
Joined: 17 Mar 2009
Online Status: Offline
Posts: 13
|
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 Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|
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 Logged |
|
shortduck
Newbie
Joined: 17 Mar 2009
Online Status: Offline
Posts: 13
|
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 Logged |
|
shortduck
Newbie
Joined: 17 Mar 2009
Online Status: Offline
Posts: 13
|
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 Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|
Posted: 18 Mar 2009 at 9:23am |
Here again, try using the interfaces: ISCRParagrah and ISCRParagraphElement.
-Dell
|
|
IP Logged |
|
shortduck
Newbie
Joined: 17 Mar 2009
Online Status: Offline
Posts: 13
|
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 Logged |
|
|