2012-01-06 10 views
1

なぜこのエラーが発生するのですか?文字列グリッドをリストビューに置き換えた後、viewstyle vsreportに設定しましたが、Delphiのフォームでメソッドの宣言にエラーを解決する

procedure TForm2.ListView2DblClick(Sender: TObject); 

の下に、この手順でその点滅を '(' が見つかり)これは私のコード

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

type 
    TForm2 = class(TForm) 
    Edit1: TEdit; 
    Edit2: TEdit; 
    ListView1: TListView; 
    ListView2: TListView; 
    procedure FormCreate(Sender: TObject); 
    procedure TForm2.ListView2DblClick(Sender: TObject); 
    private 
    { Private declarations } 
    public 
    { Public declarations } 
    end; 

var 
    Form2: TForm2; 

implementation 

{$R *.dfm} 

procedure TForm2.FormCreate(Sender: TObject); 
var 
    i: integer; 
begin 
    // NOTE: this can all be done at design-time so 
    // you don't need to do it in code at runtime! 
    ListView1.Columns[0].Width := 20; 
    ListView2.Columns[0].Width := 20; 
    for i := 0 to 49 do begin 
    ListView1.Items.Add.Caption := IntToStr(i); 
    with ListView2.Items.Add do begin 
     Caption := IntToStr(i); 
     SubItems.Add('0'); 
    end; 
    end; 
    ListView2.Columns[1].Caption := 'name'; 
    ListView1.Columns[1].Caption := 'extension'; 
    ListView1.Columns[2].Caption := 'format'; 
    ListView1.Columns[3].Caption := 'size'; 
    ListView1.Columns[4].Caption := 'date'; 
    ListView1.Columns[5].Caption := 'addres'; 
end; 

procedure TForm2.ListView2DblClick(Sender: TObject); 
var 
    Item: TListItem; 
begin 
    Item := ListView2.Selected; 
    if Item = nil then Exit; 
    if (Item.SubItems[0] <> '1024') and (Item.SubItems[0] <> '0') then 
    ListView1.Selected := ListView1.Items[StrToInt(Item.SubItems[0])]; 
end; 

end. 

です。

procedure HD; 
var 
    i: integer; 
begin 
    for i := 0 to 49 do begin 
    with form2.ListView1.Items[i] do begin 
     SubItems[0] := TABLE[i].name; 
     SubItems[1] := TABLE[i].format; 
     if TABLE[i].tip then 
     SubItems[2] := 'folder' 
     else 
     SubItems[2] := 'file'; 
     SubItems[3] := IntToStr(TABLE[i].nach); 
     SubItems[4] := IntToStr(TABLE[i].razmer); 
    end; 
    form2.ListView2.Items[i].SubItems[0] := IntToStr(fat[i]); 
    end; 
end; 

答えて

4

は、イベントハンドラの宣言でForm2.部分を取り除く:

type 
    TForm2 = class(TForm) 
    Edit1: TEdit; 
    Edit2: TEdit; 
    ListView1: TListView; 
    ListView2: TListView; 
    procedure FormCreate(Sender: TObject); 
    procedure ListView2DblClick(Sender: TObject); // <-- here 
    private 
    { Private declarations } 
    public 
    { Public declarations } 
    end; 
+0

申し訳ありませんが、私は誤植がありました。コンパイルしようとすると問題が発生しましたが、リストのインデックスが範囲外にあるというエラーがあります。 –

+0

正確にはどの行ですか?より具体的にする必要があります。 –

+0

hdプロシージャの後のリロード手順で、私はあなたに小さなプロジェクトを郵送するのですか?ここにどのように貼り付けることができますか?コードは非常に巨大です...または私はちょうどここに貼り付けるべきです –

-1

なぜユニット「終わり」を行い、以下の手順の中に表示されます。あなたが複数のユニットからコードを掲載している場合を除き単位のファイルの末尾に移動し、

procedure TForm2.ListView2DblClick(Sender: TObject); 
var 
    Item: TListItem; 
begin 
    Item := ListView2.Selected; 
    if Item = nil then Exit; 
    if (Item.SubItems[0] <> '1024') and (Item.SubItems[0] <> '0') then 
    ListView1.Selected := ListView1.Items[StrToInt(Item.SubItems[0])]; 
end; 
end. 

+0

'end.'はプロシージャ内ではありません。 –

関連する問題