RichEditFont (C++)
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
- Vcl.Controls.TControl.Font ( fr | de | ja )
- Vcl.Graphics.TFont.Name ( fr | de | ja )
- Vcl.Forms.TScreen.Fonts ( fr | de | ja )
- System.Classes.TStrings.Count ( fr | de | ja )