//RichEdit1
// 设置颜色Color
{
设置颜色后开始选中的部分仍然是选中的
}
//richedit1.SelAttributes.Color
procedure TForm1.Button1Click(Sender: TObject);
begin
RichEdit1.SelAttributes.Color
:= clRed;
end;
// 对ColorBox1
procedure TForm1.Button5Click(Sender: TObject);
begin
RichEdit1.SelAttributes.Color
:=ColorBox1.Selected;
end;
//对ColorListBox1
procedure TForm1.Button6Click(Sender: TObject);
begin
RichEdit1.SelAttributes.Color
:=ColorListBox1.Selected;
end;
//设置风格Style
//richedit1.SelAttributes.Style
{
如果要一次性设置多个文字样式的话,在中括号中用逗号隔开
richedit1.SelAttributes.Style:=[fsBold,fsItalic,fsUnderline,fsStrikeOut];
}
procedure TForm1.Button3Click(Sender: TObject);
begin
RichEdit1.SelAttributes.Style
:=[fsUnderline];
end;
//设置文字大小
procedure TForm1.Button8Click(Sender: TObject);
begin
RichEdit1.SelAttributes.Size
:=
20;
end;
//面向FontDialog1
procedure TForm1.Button3Click(Sender: TObject);
begin
if FontDialog1.Execute
then
begin
RichEdit1.SelAttributes.Assign(FontDialog1.Font);
end
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if FontDialog1.Execute
then
begin
RichEdit1.DefAttributes.Assign(FontDialog1.Font);
end
end;
//全部属性设置
procedure TForm1.Button1Click(Sender: TObject);
begin
RichEdit1.Font
:= FontDialog1.Font;
end;
//RichEdit 自动换行
procedure TForm1.Button1Click(Sender: TObject);
begin
RichEdit1.WordWrap
:=True;
end;
//with... do
procedure TForm1.Button1Click(Sender: TObject);
begin
with RichEdit1.SelAttributes
do
begin
Color
:=clBlue;
Height
:=
30;
Style
:=[fsUnderline];
end;
end;
//设置默认属性DefAttributes -> DefaultAttributes
procedure TForm1.FormCreate(Sender: TObject);
begin
with RichEdit1.DefAttributes
do
begin
Height
:=
20;
Color
:=clGreen;
Font.Name
:=
'微软雅黑';
Style
:=[fsBold,fsItalic];
end;
end;
//
procedure TForm1.FormCreate(Sender: TObject);
begin
RichEdit1.DefAttributes.Color
:=clRed;
end;
//在RichEdit中插入位图 Gif
//超链接
//