W
winbowl1122
Unregistered / Unconfirmed
GUEST, unregistred user!
在触发ListBox的OnDrawItem事件时,速度极慢,怎样优化程序,非常感谢。我的程序如下:
strName := listbox1.Items.Strings[index];
table2.First;
for i:=0 to table2.RecordCount - 1 do begin
if(strName=table2.FieldByName('busname').AsString) then begin
strMPI := table2.FieldByName('mpi').AsString;
break;
end;
table2.Next;
end;
if(strMPI<>'') then begin
listbox1.Canvas.Brush.Color := clgray;
listbox1.Canvas.Font.Color := clred;
listbox1.Canvas.TextOut(rect.Left,rect.Top,ListBox1.Items[index]);
end
else begin
listbox1.Canvas.Font.Color := clblack;
listbox1.Canvas.TextOut(rect.Left,rect.Top,ListBox1.Items[index]);
end;
table2.close;
strName := listbox1.Items.Strings[index];
table2.First;
for i:=0 to table2.RecordCount - 1 do begin
if(strName=table2.FieldByName('busname').AsString) then begin
strMPI := table2.FieldByName('mpi').AsString;
break;
end;
table2.Next;
end;
if(strMPI<>'') then begin
listbox1.Canvas.Brush.Color := clgray;
listbox1.Canvas.Font.Color := clred;
listbox1.Canvas.TextOut(rect.Left,rect.Top,ListBox1.Items[index]);
end
else begin
listbox1.Canvas.Font.Color := clblack;
listbox1.Canvas.TextOut(rect.Left,rect.Top,ListBox1.Items[index]);
end;
table2.close;