关于改变文字粗细倾斜的枚举类型的一个问题! 谢谢。(20)

N

netsen

Unregistered / Unconfirmed
GUEST, unregistred user!
我想是Memo1里面的文字状态发生变化 先定义了一个枚举类型,如下type TFontStyle=(fsBold,fsItalic,fsUnderline,fsStrikeOut); TFontStyles=set of TFontStyle;我再进行操作的时候添加了3个CheckBox,在他们的OnClick事件上写如下的procedure TForm1.CheckBox1Click(Sender: TObject);begin if CheckBox1.Checked then Memo1.Font.Style:= Memo1.Font.Style+[fsBold] else Memo1.Font.Style:= Memo1.Font.Style-[fsBold] ;end;procedure TForm1.CheckBox2Click(Sender: TObject);begin if CheckBox2.Checked then Memo1.Font.Style:= Memo1.Font.Style+[fsItalic] else Memo1.Font.Style:= Memo1.Font.Style-[fsItalic] ;end;procedure TForm1.CheckBox3Click(Sender: TObject);begin if CheckBox3.Checked then Memo1.Font.Style:= Memo1.Font.Style+[fsUnderline] else Memo1.Font.Style:= Memo1.Font.Style-[fsUnderline] ;end;为什么老是出错呢! 那个帮小弟解决一下,谢谢了
 
正常的啊,如下:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, TeEngine, Series, DB, DBTables, ExtCtrls, TeeProcs, Chart, DbChart, StdCtrls;type// TFontStyle=(fsBold,fsItalic,fsUnderline,fsStrikeOut); TFontStyles=set of TFontStyle; TForm1 = class(TForm) CheckBox1: TCheckBox; CheckBox2: TCheckBox; CheckBox3: TCheckBox; Memo1: TMemo; procedure CheckBox1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.CheckBox1Click(Sender: TObject);begin if CheckBox1.Checked then Memo1.Font.Style:= Memo1.Font.Style+[fsBold] else Memo1.Font.Style:= Memo1.Font.Style-[fsBold] ; if CheckBox2.Checked then Memo1.Font.Style:= Memo1.Font.Style+[fsItalic] else Memo1.Font.Style:= Memo1.Font.Style-[fsItalic] ; if CheckBox3.Checked then Memo1.Font.Style:= Memo1.Font.Style+[fsUnderline] else Memo1.Font.Style:= Memo1.Font.Style-[fsUnderline] ;end;---------------------我把TFontStyle=(fsBold,fsItalic,fsUnderline,fsStrikeOut);隐含了,否则无法编译
 
恩 好了,谢谢了!可是为什么注释掉才能编译呢!
 

Similar threads

I
回复
0
查看
392
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
510
import
I
顶部