修复Delphi中表单中的方法声明中的错误 [英] Fixing an error in a method declaration in a form in Delphi

查看:97
本文介绍了修复Delphi中表单中的方法声明中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么会出现此错误,我将stringgrid替换为listview,然后将其设置为viewstyle vsreport,但是却遇到了类似(预期'='但'('找到)的错误,它在下面的过程中闪烁

Why am I getting this error, I replaced a stringgrid with a listview, I then set it to viewstyle vsreport but I am getting an error like (expected '=' but '(' found) its flashing on this procedure below

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;


推荐答案

摆脱 Form2在事件处理程序的声明中。

Get rid of the Form2. portion in the declaration of the event handler:

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; 

这篇关于修复Delphi中表单中的方法声明中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆