RichEditFont (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

To use this example, place a TComboBox and a TRichEdit or a TMemo on a form. During the form creation, a list of font names is loaded into the combo box. When the combo box is clicked, the memo or Rich Edit control font is set to the corresponding font name in the combo box.

Code

procedure TForm1.FormCreate(Sender: TObject);
var
  i : Integer;
begin
  for i := 0 to Screen.Fonts.Count - 1 do
   ComboBox1.Items.Add(Screen.Fonts.Strings[i]);
//  ComboBox1.Items := Screen.Fonts;  // This is another way to do it.
  RichEdit1.Lines.Text := 'How is it to be you?';
end;

procedure TForm1.ComboBox1Click(Sender: TObject);
begin
  RichEdit1.Font.Name := ComboBox1.Text;
end;

Uses