listView刷屏(线程中插入多行数据) ( 积分: 15 )

  • 主题发起人 主题发起人 crasyProg
  • 开始时间 开始时间
C

crasyProg

Unregistered / Unconfirmed
GUEST, unregistred user!
我在线程中同步更新ListView行数据,可是ListView不停的闪烁,这个问题怎么解决阿?
 
我在线程中同步更新ListView行数据,可是ListView不停的闪烁,这个问题怎么解决阿?
 
type
TListViewThread = class(TThread)
private
FIndex: Integer;
FListView: TListView;
proceduredo
AddItem;
protected
procedure Execute;
override;
public
constructor Create(AListView: TListView);
end;

{ TListViewThread }
constructor TListViewThread.Create(AListView: TListView);
begin
FListView := AListView;
FreeOnTerminate := True;
inherited Create(False);
end;

procedure TListViewThread.DoAddItem;
begin
Inc(FIndex);
with FListView.Items.Adddo
begin
Caption := IntToStr(FIndex);
SubItems.Add('Item' + IntToStr(FIndex));
SubItems.Add('Memo' + IntToStr(FIndex));
end;
Application.ProcessMessages;
end;

procedure TListViewThread.Execute;
var
I, K: Integer;
begin
I := 1;
while not Terminated and (I <
1000)do
begin
for K := 1 to 20do
Synchronize(DoAddItem);
Sleep(1000);
Inc(I);
end;
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
TListViewThread.Create(ListView1);
end;
 
我解决问题了,设置一个叫做doubl。。为true,就可以了
 
后退
顶部