大家都知道,Tfontstyles是一个类型集合,即:Tfontstyles=set of Tfontstyle.
Tfontstyle=(fsbold,fsunderline,fsItalic,fsDtrikeout).
我现在想把fsbold,fsunderline,fsItalic,fsDtrikeout显示在checkbox中,怎么做?这只是举个例子,我的项目中自己编写的控件中需要这么做,只是用Tfontstyle说说问题,道理是一样的!谢谢!!!

解决方案 »

  1.   

    for i:=0 to integer(high(TJeactionbit))-1 do
     begin
      cb_mb_jeaction_bit.Items.Add(!这里怎么写?!);
     end;
      

  2.   

    Tfontstyle=(fsbold,fsunderline,fsItalic,fsDtrikeout).
    是一个枚举型.
    枚举型的实质是有序的数字.
    可以做一个数组.
    fontStyleStr:array [TFontStyle] of string = ('粗体','下划线','斜体','删除线');Tfontstyles=set of Tfontstyle.
    是一个集合.
    可以用in操作.例如:
    var
    fontstyles:TFontStyles;if fsbold in fontstyles then
      checklistbox.items.add(fontStyleStr[fsbold]);再举一个例子:
    var
      i:TfontStyle;for i:=fsbold to fsDtrikeout do
    begin
      if s=fontStyleStr[i] then  //这里的s就是你显示在界面上的字符串.想怎么弄就怎么弄
      begin
        .....//这里就可以做你想做的操作,i就是结果.
        break;
      end
    end;明白的话,就可以举一反三了.其他枚举型和集合型都可以类似操作.
      

  3.   

    for i:=0 to integer(high(TFontstyle))-1 do
     begin
      cb_mb_jeaction_bit.Items.Add(!这里怎么写?!);
     end;
      

  4.   

    枚举类型的集合元素名称,只是在编译前有效,编译后,就不复存在。所以你要自己写代码。用Case分支即可   (上述言论,个人看法)
      

  5.   

    JeactionbitStr:array[TJeactionbit] of string =('厘','分','角','各','十','百','千','万','十万','百万','千万','亿','十亿','百亿','千亿','万亿','十万亿');这个怎么有错误啊/
      

  6.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}function ComponentToString(Component: TComponent): string;var
      BinStream: TMemoryStream;
      StrStream: TStringStream;
      s: string;
    begin
      BinStream := TMemoryStream.Create;
      try
        StrStream := TStringStream.Create(s);
        try
          BinStream.WriteComponent(Component);
          BinStream.Seek(0, soFromBeginning);
          ObjectBinaryToText(BinStream, StrStream);
          StrStream.Seek(0, soFromBeginning);
          Result := StrStream.DataString;
        finally
          freeandnil(StrStream);    end;
      finally
        freeandnil(BinStream)
      end;
    end;function StringToComponent(Value: string): TComponent;
    var
      StrStream: TStringStream;
      BinStream: TMemoryStream;
    begin
      StrStream := TStringStream.Create(Value);
      try
        BinStream := TMemoryStream.Create;
        try
          ObjectTextToBinary(StrStream, BinStream);
          BinStream.Seek(0, soFromBeginning);
          Result := BinStream.ReadComponent(nil);    finally
          freeandnil(BinStream);
        end;
      finally
        freeandnil(StrStream);
      end;
    end;function fontTostr(V: Tfont): string;
    var
      fd: TFontDialog;
    begin
      fd := TFontDialog.Create(nil);
      fd.Font.Assign(v);
      Result := ComponentToString(fd);
      FreeAndNil(fd);
      Result := StringReplace(Result, #13, '', [rfReplaceAll]);
      Result := StringReplace(Result, #13, ';', [rfReplaceAll]);
    end;function strTofont(V: string; font: Tfont): boolean;
    var
      fd: TFontDialog;
    begin
      Result := false;
      if v = '' then
        exit;
      try
        V := StringReplace(v, ';', #13, [rfReplaceAll]);    fd := TFontDialog(StringToComponent(V));
        font.Assign(fd.Font);    FreeAndNil(fd);
        Result := true;
      except;
      end;end;procedure TForm1.Button1Click(Sender: TObject);
    var
      s: string;
    begin
      s := fontTostr(Font);
      ShowMessage(s);
      strTofont(s, Font);
    end;
    initialization
      RegisterClass(TFontDialog);
    end.
      

  7.   

    不只 font 你就是一个 Form 都可以你看看 DREAM 都可以 直接 run 源码