Board index » delphi » RichEdit not formatting text properly...

RichEdit not formatting text properly...

I'm trying to add some text to a richedit control so that I get a bold header line, then a bulleted list full of info then another header and more lists and so on. And it works fine until the text scrolls out of the window, then the control doesn't format the text properly (in fact all the bold is gone and it looks like the headers are the lists and the list items are just plain text).

the code I'm using is: ("summary" is the richedit control)

       for i := 0 to 6 do
            begin
              Summary.Paragraph.Numbering := nsNone;
              Summary.SelAttributes.Style := [fsBold];
              Summary.Lines.Add(title);
              Summary.SelAttributes.Style := [];
              Summary.Paragraph.Numbering := nsBullet;
              if RunQuery(queryString, testResult) then
                 begin
                      s := testresult.somevalue;
                      Summary.lines.add(s);
                 end;
              Summary.Paragraph.Numbering := nsNone;
              Summary.Lines.Add('');
            end;

Do I have to use something besides SelAttributes to do what I want? And, if so, can anyone explain why it works on the text you can see, but doesn't on the text you can't (without scrolling anyway)

Thanks in advance!
Bryan

 

Re:RichEdit not formatting text properly...


In <3caa247b$1_1@dnews>, Bryan Murphy wrote:

Quote
>        for i := 0 to 6 do
>             begin
>               Summary.Paragraph.Numbering := nsNone;
>               Summary.SelAttributes.Style := [fsBold];
>               Summary.Lines.Add(title);
>               Summary.SelAttributes.Style := [];
>               Summary.Paragraph.Numbering := nsBullet;
>               if RunQuery(queryString, testResult) then
>                  begin
>                       s := testresult.somevalue;
>                       Summary.lines.add(s);
>                  end;
>               Summary.Paragraph.Numbering := nsNone;
>               Summary.Lines.Add('');
>             end;

Bryan

I think this is a fairly well-established bug in RichEdit - the control
needs to have focus, when you start pushing the caret beyond the
visible area, otherwise it doesn't scroll itself properly.  Unless
you're calling this code from within some kind of focus-switching logic
(in which case life gets a bit more complex), the easy fix would be to
insert before your code

  activecontrol := summary;

Roger Morton
ro...@chez-morton.com

Re:RichEdit not formatting text properly...


Quote
In article <3caa247b$1_1@dnews>, Bryan Murphy wrote:
> I'm trying to add some text to a richedit control so that I get a bold
> header line, then a bulleted list full of info then another header and
> more lists and so on. And it works fine until the text scrolls out of the
> window, then the control doesn't format the text properly (in fact all
> the bold is gone and it looks like the headers are the lists and the
> list items are just plain text).

Try to set the HideSelection property of the richedit to false. Some things
do not work properly if it's true and the control does not have focus.

Quote
> the code I'm using is: ("summary" is the richedit control)

>        for i := 0 to 6 do
>             begin
>               Summary.Paragraph.Numbering := nsNone;
>               Summary.SelAttributes.Style := [fsBold];
>               Summary.Lines.Add(title);

In my experience it is best to avoid Lines.Add if you try to modify attributes
at the same time. Instead add text by assigning it to the SelText property. To
force a linebreak add a #13#10 sequence to the text.

--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Other Threads