1

我有一个TJVSegmentedLEDDisplay要用作计时器的控件(来自 JVCL)。因此,它有五个位置,两个代表小时,两个代表分钟,两个数字之间有一个冒号(即 12:34)。经过数小时的试验和搜索,我仍然无法弄清楚如何以编程方式访问每个单独的数字。在我看来,它应该是这样的:

LEDControl.Digits[Index].Text

...但是,显然,它不是。

有什么想法吗 ?

4

1 回答 1

1

您尝试访问的TJvCustomSegmentedLEDDigit.Text属性受到我要说的错误的保护,从那时起,除了直接修改Text属性之外,这不太舒服,我找不到如何更改各个段值的方法。但是,您可以通过插入器类来解决这种受保护的访问:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, JvExControls, JvSegmentedLEDDisplay;

type
  TLEDDigit = class(JvSegmentedLEDDisplay.TJvCustomSegmentedLEDDigit);

type
  TForm1 = class(TForm)
    Button1: TButton;
    JvSegmentedLEDDisplay1: TJvSegmentedLEDDisplay;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  TLEDDigit(JvSegmentedLEDDisplay1.Digits[0]).Text := '1';
  TLEDDigit(JvSegmentedLEDDisplay1.Digits[1]).Text := '2';
end;

end.
于 2012-12-09T02:16:12.850 回答