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
Solved

assigning FONT in richedit

Posted on 2002-06-19
6
438 Views
Last Modified: 2013-12-03
Whats wrong with my code why my richedit will not change its font when it comes with Wingdings and Marlett etc..

RichEdit1.Font.name := FontName.items[FontName.itemindex];

where [fontName] contains LIST OF FONT NAMES like

Arial
Arial Black
Wingdings
Wingding1
Wingding2
etc..
0
Comment
Question by:girlswants_me
6 Comments
 

Author Comment

by:girlswants_me
ID: 7094620
can you give me the exact code for it?
thank you in advance
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 100 total points
ID: 7094880
Hello

  use SelAttributes instead of Font to change the font of selected Text

  RichEdit1.SelAttributes.Name := FontName.Items[FontName.ItemIndex];
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7094881
a guess

this line
RichEdit1.Font.name := FontName.items[FontName.itemindex];
changes only the defaultattributes

if you want to change the font you must first select the whole text and apply your font to the selattributes like

richedit1.selstart := 0;
richedit1.sellength := length(Richedit1.lines.text);
//maybe there is a richedit.selectall;
richedit.selattributes.font.name := FontName.items[FontName.itemindex];

just from head, not tested

meikl ;-)
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:girlswants_me
ID: 7094966
it still dont work
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7094974
is the font available on the system?
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 7096872
Try this:

procedure TForm1.FormCreate(Sender: TObject);
begin
 Listbox1.items:=Screen.Fonts;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 RichEdit1.Font.name:=Listbox1.items[Listbox1.itemindex];
 RIchEdit1.Text:='DrDelphi rules';
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
 RichEdit1.Selstart:=0;
 RichEdit1.Sellength:=3;
 RichEdit1.SelAttributes.Name:=Listbox1.items[listbox1.itemindex];

end;



This works for me here, with every font that appears in the listbox. Good luck!!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 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