?
Solved

Edit box/individual chars

Posted on 2005-03-21
6
Medium Priority
?
236 Views
Last Modified: 2010-04-05

Is there a way to bold and color an individual character in an edit box?  (Using D5, in other words, if an edit box says "this is a test", I want to make "a" bold and green, an change it on the fly)

Thanks
0
Comment
Question by:jexd99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 46

Expert Comment

by:aikimark
ID: 13593994
No.

That formatting would require a different control, such as RTF or web browser.

You could display the text formatted by printing on a canvas.  This would not be an editable control.
0
 
LVL 17

Expert Comment

by:mokule
ID: 13594159
You can use TRichEdit setting
  RichEdit1.WordWrap := False;
  RichEdit1.WantReturns := False;
set also its height to such as edit

mokule
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 total points
ID: 13601561
Along with mokule's answer, here is how to do it:

procedure TForm1.RichEdit1KeyUp
  ( Sender: TObject;
    var Key: Word;
    Shift: TShiftState
    );
var
  loc: Integer;
  oldcolor: TColor;
  oldStyle:  TFontStyles;
begin
  oldcolor := RichEdit1.SelAttributes.Color;
  oldstyle := RichEdit1.SelAttributes.Style;
  if Key = 65 then
  begin
    loc := RichEdit1.SelStart;
    RichEdit1.SelStart := loc-1;
    RichEdit1.SelLength := 1;
    RichEdit1.SelAttributes.Color := clGreen;
    RichEdit1.SelAttributes.Style := [fsBold];
    RichEdit1.SelStart := loc + 1;
  end;
  RichEdit1.SelAttributes.Color := oldcolor;
  RichEdit1.SelAttributes.Style := oldstyle;
end;

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Expert Comment

by:ZhaawZ
ID: 13604046
I think this could be done by using some winapi functions, but this is not the easiest way.
0
 

Author Comment

by:jexd99
ID: 13606134
Thanks everyone, bummer I can't do this with an editbox but I'll make it work with richedit.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 13611778
[quote]I can't do this with an editbox[/quote]
Correct as was stated by aikimark. The standard Windows
Edit control does not support colors, UNLESS, you do all
the drawing yourself and that would take a lot more
code than is shown.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

771 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