Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 2 Jahren, 8 Monaten
Letzter Beitrag:
vor 2 Jahren, 8 Monaten
Beteiligte Autoren:
Naveen Rathan, Alexandre Leclerc, GuenterP, Fabrice Harari, Paulo Oliveira, Tor-Bjarne

Different font color in edit control

Startbeitrag von Naveen Rathan am 09.06.2015 12:42


I am using a edit control where I am appending text through code. My requirement is alternate font color like below:
Line 1 in blue color
Line 2 in black color

Any help how to achieve this?

Thanks and Regards,
Naveen Rrathan


you can define your edit control as RTF it's easy.

just check the WD Coloring Search Example

von Paulo Oliveira - am 09.06.2015 13:37
Hi Paulo,

WD Coloring example you mentioned is not helping.

Actually each time I append to my edit control I have to do it with different color,. That is my requirement. Any help?

Thanks and Regards,
Naveen Rathan

von Naveen Rathan - am 09.06.2015 14:17

you can probably do that with the dpen function

Best regards

von Fabrice Harari - am 09.06.2015 14:23
Hi Fabrice,

dPen is not working. Actually I want something like below snippet to work.

EDT_MyEdit = "text1"
EDT_MyEdit..Color = DarkBlue
EDT_MyEdit = "text2"
EDT_MyEdit..Color = Black
EDT_MyEdit = "text3"

But this way whole contents are changing their color to the mentioned. But I want only text2 to be in blue and text3 to be in black.

Any help?

Thanks and Regards,
Naveen Rathan

von Naveen Rathan - am 10.06.2015 07:09

I Would probably solve this with my SyntaxEdit component (Component one)

But if you are able to colorize one rtf edit (with one color) why dont you use 2 rtf edit`s?

Edt_Main_Rtf = "" //To hold everything
Edt_One_rtf = "" // Pr line

Edt_One_rft = "Text line 1"
edt_one_rtf..color = //Or whatever you do to colorize a whole rtf colotrol with text

RTFAdd(Edt_Main_rtf ,edt_one_rtf)

Edt_One_rft = "Text line 2"
edt_one_rtf..color = //Or whatever you do to colorize a whole rtf colotrol with text


And so forth ..


von Tor-Bjarne - am 10.06.2015 07:52
Hi, the 'problem' here is 'knowledge' and ok, it's a bit complicated. It's some years ago when I wrote a WINDEV program which managed RTF-Text (partly automatically) for about 20 different languages and scripts like Georgian and Russian targeting a label printer. And yes, I had to study the RTF specifications ( http://www.biblioscape.com/rtf15_spec.htm ) in order to be able to do what our customer wished. If you really want to stay with RTF then this is your way to go!

I believe that your task is much easier to accomplish, because nowadays you can use an HTML-control and generate a document by adding a header and a body and insert the lines of text with the known tags for font, color and size into the body of that HTML-document. This would circumvent the necessity of studying the RTF-specs. At the end you still could use the HTMLtoRTF(...) function in order to get a 'plain' RTF-text from the HTML-control.

von GuenterP - am 10.06.2015 08:26
Hi Naveen,

With a RTF control this is fairly easy to do. Here is a simple example:

// Put the following code in the "initialization" section of any RTF control
s1 is string = "Line in RED"
s2 is string = "Line is GREEN"
s3 is string = "Line in BLUE"
RTFAdd(MySelf, RTFSelection(s1,rtfColor,LightRed,1,Length(s1)))
RTFAdd(MySelf, RTFSelection(s2,rtfColor,LightGreen,1,Length(s2)))
RTFAdd(MySelf, RTFSelection(s3,rtfColor,LightBlue,1,Length(s3)))

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 10.06.2015 12:26

[SOLVED]Re: Different font color in edit control

Hi Alexandre,

Thanks a ton. You gave the simplest solution of all.

Naveen Rathan

von Naveen Rathan - am 10.06.2015 14:04
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.