listboxhelperform.pas

来自「source code for Marco Cantu s book Delph」· PAS 代码 · 共 50 行

PAS
50
字号
unit ListboxHelperForm;

interface

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

type
  TForm10 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form10: TForm10;

implementation

{$R *.dfm}

type
  TListboxHelper = class helper for TListBox
    function ItemIndexValue: string;
  end;


procedure TForm10.Button1Click(Sender: TObject);
begin
  ShowMessage (ListBox1.ItemIndexValue);
//  ShowMessage (
//    ListBox1.Items [ListBox1.ItemIndex]);
end;

{ TListboxHelper }

function TListboxHelper.ItemIndexValue: string;
begin
  Result := '';
  if ItemIndex >= 0 then
    Result := Items [ItemIndex];
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?