代码之家  ›  专栏  ›  技术社区  ›  Mariner

如何更改标签的dragmode属性(firemonkey)

  •  1
  • Mariner  · 技术社区  · 6 年前

    这对你们来说一定很简单,但我不知道问题出在哪里。代码如下:

    unit Unit7;
    
    interface
    
    uses
      System.SysUtils, System.Types, System.UITypes, System.Classes, 
      System.Variants,
      FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, 
      FMX.StdCtrls,
      FMX.Controls.Presentation;
    
    type
      TForm7 = class(TForm)
        Button1: TButton;
        Label1: TLabel;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form7: TForm7;
    
    implementation
    
    {$R *.fmx}
    
    procedure TForm7.Button1Click(Sender: TObject);
    begin
    label1.dragmode:=dmautomatic;
    end;
    
    end.
    

    我所做的就是创建一个表单,在其上放置一个标签和一个按钮,并尝试更改 DragMode 要删除的标签的属性 dmAutomatic 单击按钮时。

    程序不会编译,编译器只是声明:

    未声明的标识符:dmautomatic。

    我错过了一些非常明显的东西,但我看不出是什么。

    1 回复  |  直到 6 年前
        1
  •  4
  •   Remy Lebeau    6 年前

    FireMonkey编译时使用 Scoped Enums 启用。所以,你必须加前缀 dmAutomatic 使用其枚举类型名称, TDragMode ,例如:

    Label1.DragMode := TDragMode.dmAutomatic;