RichEditFont (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

To use this example, place a TComboBox and a TRichEdit or TMemo on a form. During 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

__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
  for (int i = 0; i < Screen->Fonts->Count; i++)
   ComboBox1->Items->Add(Screen->Fonts->Strings[i]);
//  ComboBox1->Items = Screen->Fonts;  // Another way to do it
}

void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
  RichEdit1->Font->Name = ComboBox1->Text;
}

Uses