Solved

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

Posted on 2003-12-12
26
663 Views
Last Modified: 2013-11-23
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
0
Comment
Question by:rk001
  • 15
  • 5
  • 3
  • +1
26 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9928339
what about a TRichEdit or TMemo?
0
 

Author Comment

by:rk001
ID: 9928494
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
 

Author Comment

by:rk001
ID: 9928503
or please suggest some other possible solution.
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 1

Expert Comment

by:FeralCTO
ID: 9928885
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
 

Author Comment

by:rk001
ID: 9929018
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
 
LVL 1

Accepted Solution

by:
tormork earned 25 total points
ID: 9929355
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
 

Author Comment

by:rk001
ID: 9929641
Hello tormork,

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

thanks
pvp
0
 

Author Comment

by:rk001
ID: 9929644
Hello tormork,

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

thanks
rk
0
 

Author Comment

by:rk001
ID: 9930085
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
 

Author Comment

by:rk001
ID: 9930291
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9931023
why not use quickreport/reportbuilder or any other report-component?
0
 

Author Comment

by:rk001
ID: 9934870
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
 

Author Comment

by:rk001
ID: 9935061
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
 
LVL 1

Expert Comment

by:tormork
ID: 9941278

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
 

Author Comment

by:rk001
ID: 9941985
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
 
LVL 1

Expert Comment

by:tormork
ID: 9942113
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9942124
look at

richedit1.Paragraph.LeftIndent := whatever
0
 

Author Comment

by:rk001
ID: 9950276
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9950544
what does
update(fileaname.rtf);
?
0
 

Author Comment

by:rk001
ID: 9950593
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
 
LVL 27

Assisted Solution

by:kretzschmar
kretzschmar earned 25 total points
ID: 9950642
??
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
 

Author Comment

by:rk001
ID: 9950660
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
 

Author Comment

by:rk001
ID: 9950738
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
 

Author Comment

by:rk001
ID: 9950938
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

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question