Need a suggestion: to display the data on a standard Delphi component

Hello All!

              I have to display(like a report) some data which generate dynamically from my program. I have some 50 lines of data, including some static text.

       Is there any Delphi control(like panel) where we can design the statictext and keep some texfields for dynamic text.

requirements of a control:
         1. It should be scrolled when the data crosses the boundaries of the control.
         2. The can be printable.

could you suggest a possible standard component to perform my requirement with small example.

regards
rk
rk001Asked:
Who is Participating?
 
tormorkConnect With a Mentor Commented:
I agree with kretzschmar about the RichEdit.

procedure Example;
var sl: TStringList;
begin
  // Setting the first 5 charecters green and bold
  RichEdit1.SelStart := 0;
  RichEdit1.SelLength := 5;
  RichEdit1.SelAttributes.Color := clGreen;
  RichEdit1.SelAttributes.Style := RichEdit1.SelAttributes.Style + [fsBold];

  // show scrollbars
  RichEdit1.ScrollBars := ssBoth;

  // Save to rtf-file
  RichEdit1.Lines.SaveToFile('c:\somefile.rtf');

  // Save to txt file
  sl := TStringList.Create;
  sl.Text := RichEdit1.Lines.Text;
  sl.SaveToFile('c:\somefile.txt');
  sl.destroy;

  // Print
  RichEdit1.Print('Sometitle')
end;


If you set all bevels to bvNone and border to bsNone in the obj. inspector and color := clButton it will even look like a form.
You problably want to set it to read only, since it's a report, but using a RichEdit has an additional advanage in that you can copy and paste to text to another progam.

0
 
kretzschmarCommented:
what about a TRichEdit or TMemo?
0
 
rk001Author Commented:
Hello,

          with TRichEdit and TMemo my requirements wont be solved, because my requirements are below:

 1. i need to format the static text before, for example

     line no:1   Temparature(static text, left 100, Bold properties)       : label1 (in this place dynamic text will be filled)
     line no:2
      ---- and so on-----.(must be scrollable)

2. The content must be printable

3. The content should be saved as a file.

so you suggested controls cant solve my problem.

Please suggest one component, which can solve above my 3 requirements with small example.

regards
rk
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
rk001Author Commented:
or please suggest some other possible solution.
0
 
FeralCTOCommented:
If I understand what you're trying to do, it sounds like a case for HTML. You can do any formatting you want, start with a template if appropriate and fill in the dynamic content at runtime, and you have a couple of different options for displaying it.

Regards,

Ron
"FeralCTO"
0
 
rk001Author Commented:
Hello FeralCTO,

            Your suggestion is nice. I am a beginner in programming. I dont know how to communicate HTML or Word document with Delphi, and displying it at the runtime as a Report. Could you help me in making a small example for this complete process.

regards
rk
0
 
rk001Author Commented:
Hello tormork,

     I will try to experiment on your example, and i will respond you soon.

thanks
pvp
0
 
rk001Author Commented:
Hello tormork,

     I will try to experiment on your example, and i will respond you soon.

thanks
rk
0
 
rk001Author Commented:
hello,

         RichEdit working nicely, but i am getting an exception while i am trying to print.

    RichEdit1.print('My Doc');

The Exception: 'External Exception c000008', how can i solve this error.

thanks
rk
0
 
rk001Author Commented:
I am unable to have the Horizontal scroll bar even  i set

RichEdit1.scrollbars := ssBoth;

in my case printing the data is important task. could you say is there any way to show 'Pritn Dialogue' also, which provide printlayout and selecting the printer etc.

could you suggest me how to solve above problems.

thanks
rk
0
 
kretzschmarCommented:
why not use quickreport/reportbuilder or any other report-component?
0
 
rk001Author Commented:
Hello,

         i have never worked  with any reporting component(like quickreport).  That is why, to make the report in a easy way i have choosen TRichEdit, for my purpose... as i need to submit my application to my professor soon.

-------------------------------------------------------------------------------
         i explain you the current scenario regarding my reports:

                                 i need to generate 2 reports. for one report, i have a word document(in this i am using MailMerge functionality, with .txt as datasource, and it is writing from delphi app.)
       
                   RichEdit1.Lines.LoadFromFile('c:\report1.rtf')  ---> i formatted everything in the .rtf it self

so it is looking nice, but, RichEdit1.print('rpt'); is generating exception, and  also need 'print setup' dialogue.

Another report i had to generate from code it self..i tried it:
                   
                           RichEdit1.Lines.Add('string1');....like this i am able fill the data. in this case if i want to format some specified line say, line no: 10, to be bold... i dont know how to do it(Richedit1.selstart, with this we have to tell the characters, but i want to tell the line no. to format)

-----------------------------------------------------------------------

if i am able to solve, showing PrintSetup dialogue and Formating specified line with RichEdit, it would be a good solution for me.

You please try to suggest me how to solve above 2 probs. with RichEdit, as it seems i can complete my task quickly.

If you think above 2 functionalities not possible with TRichEdit component, then please provide me few lines of code for qucireport:
             1. How to load a file,(.doc or .rtf) in to quickreport.--> which should be having scroll bar
             2. How to save a report as a file.
and some other important related points.

waiting for your suggestion..........

thanks
rk001




               





       
0
 
rk001Author Commented:
i solved 'printsetup Dialogue'  using TPrintDialog component.

          now please tell me how to avoid :

                        'External exception C00000008'   exception while printing.

and how to format a specified line in the RichEdit lines.

thanks
pvp
0
 
tormorkCommented:

RichEdit1.scrollbars := ssBoth;
The reason for the missing scrollbars is problably that you have WordWrap=true. If WordWrap=false the lines can continue past the right margin (Well there is no rigth margin)

With wordwrap=false it is also easier to calculate where each line start by accumulating Lengt(RichEdit1.Lines[0])+Lengt(RichEdit1.Lines[1])... You can then use this as RichEdit1.SelStart(Maybe you'll have to add 1 or 2 to each line to accomodate linefeed, I can't remeber)

I do not know why you get 'External exception C00000008', sorry :)
0
 
rk001Author Commented:
Thanks tormork,

        i think  'External exception C00000008' this exception is due to printer driver problem. i will solve it.

could you say how to give left margin to the current line in RichEdit,
       eg:
                     line1
                         line2
                     line3

these lines will be added dynamically. here for line2, it needs some left margin.

is there any thing like
        Richedit1,selAttributes.left := 10; ---> i know this is wrong statement :) just to get an idea

thanks
pvp
0
 
tormorkCommented:
Yea, when you selstart is in a paragraph you can use:
  RichEdit1.Paragraph.FirstIndent  := 10;
  RichEdit1.Paragraph.LeftIndent := 20;
The first line will have an indent of 10 and the rest 20 px
0
 
kretzschmarCommented:
look at

richedit1.Paragraph.LeftIndent := whatever
0
 
rk001Author Commented:
Hello,

NOT LOADING THE UPDATED FILE
           I have a new problem with RichEdit:

procedure btnclick()
begin
update(fileaname.rtf); //this is my procedure, here file.rtf is updated

//ReportsDisp --> TRcihEdit

ReportsDisp.ReadOnly := true;
ReportsDisp.Clear;
ReportsDisp.Lines.Clear;
ReportsDisp.ReadOnly := false;
ReportsDisp.Lines.LoadFromFile(filename.rtf);
ReportsDisp.ReadOnly := true;
end;

Even though i have updated the file.rtf successfully with new data, Richedit is not showing the updated file data, but it is showing previous data.

could you suggest me how to solve this problem

thanks
pvp1
0
 
kretzschmarCommented:
what does
update(fileaname.rtf);
?
0
 
rk001Author Commented:
Hello  kretzschmar,

        update(fileaname.rtf);  in this procedure call, i am updating a DataSource(it is a text file, souce.txt). And using this DataSource and MailMerge concept i am making a new updated .rtf file.(previously for this file the datasouce has been opend with .txt file).

after update(fileaname.rtf); procedure call only i am tying to load the .rtf file into the RichEdit control. But it is not displying the updated data.

Note: when i am trying to open this particular .rtf file to be loaded in to the RichEdit control, manually then i found data has been modified.

please tell me how can i solve this problem.

thanks
pvp1
0
 
kretzschmarConnect With a Mentor Commented:
??
usual i would guess
- the file is not updated
or
- you load the wrong file (check the filename)

otherwise, maybe the os gets an older version from cache
(guess that isn't it)

meikl ;-)
0
 
rk001Author Commented:
Hello  kretzschmar,

           one more point when i open this updated .rtf file manuall and save it, and then if i execute my application RichEdit is loading the updated .rtf file. i am unable to understand why it is happening.

please give me a suggestion.

thanks
0
 
rk001Author Commented:
one more point... the .rtf has been created using office 97 as the application should work for both with office 97 and office 2000. if you want i can show the source code for opening the data source for the rtf file.

             
0
 
rk001Author Commented:
Hello ,

if there any possibility of converting .doc file to .rtf before  ReportsDisp.Lines.LoadFromFile(filename.rtf); statement. If i am able to do this i may solve my problem.

thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.