Home > Back-end >  Delphi data list control (ListView, DBGrid) follow-up questions
Delphi data list control (ListView, DBGrid) follow-up questions

Time:09-15

The problem of the last post, continue to study, hope to answer
a great godhttps://bbs.csdn.net/topics/392406195

Contrast the ListView and DBGrid directly write data rate (60 3000 data, each data field)
DBGrid: Append, FieldByName writing takes more than 2 seconds,
ListView: SubItems. Add writing takes more than 4 seconds
Light so see DBGrid appeared to be slightly better
But ListView has a OwnerData property, after open OnData method is used to refresh the data of the time only 0.02 seconds

So the question is coming, whether the DBGrid have ListView this mechanism, brush out data are not considered part of the screen, scroll down to brush out
If any want to how to implement, best can put a simple code, of course, don't use click the next Page this way, such as the Page Down need like ListView display a Page, scroll Down natural brush out

CodePudding user response:

One could argue, since refresh the ListView control efficiency is high, so why idle egg pain I also want to change ListView to DBGrid
And controls a change, the interface associated with this control code to rewrite all, time-consuming effort
There are two main reasons,
1, DBGrid controls may be increased to a field data types not ListView, and practice requires more data types to determine left to align right alignment, or other effects, ListView can only each field to adjust manually, too much trouble, at present already has more than 60 field, happen to the back with the increase of demand field continues to become more, maintain too tired
2, sorting, now before the OnData refresh data, first to a Tlist data using a Sort Sort, time consuming, peak interface may be directly stuck (the interface data real-time demand is very high, if monitoring 3000 customers, real-time advocate refresh, peak may refresh rate) hundreds of thousands of times per second, and DBGrid is ordered to by adding the index field, efficiency is much faster,

CodePudding user response:

I this case can set a packetRecords ClientDataSet?
But packetRecords I enter an item number, or not do, don't know how to use

CodePudding user response:

FetchOnDemand set to True, packetRecords set up 50, but the brush

CodePudding user response:

The last time is not already solved the DBGrid performance issues? Was 3000 rows and three columns of data, it only took 0.012 seconds, I had a test today, even 60 columns, also only 0.25 seconds, your computer or network is slow?

CodePudding user response:

If you take Firedac Delphi, use TFDMemTable instead of the TClientDataSet, 60 listed 3000 rows of data only 0.12 seconds to complete

CodePudding user response:

reference 4 floor BlueStorm response:
the last post is not already solved the DBGrid performance issues? Was 3000 rows and three columns of data, it only took 0.012 seconds, I had a test today, even 60 columns, also only 0.25 seconds, your computer or network is slow?


Before the main is no test field, two or three field is very fast, but the test 60 field just stuck up, is I didn't write the code, and now I don't use delphi6 TFDMemTable

 procedure TForm1. Button1Click (Sender: TObject); 
Var
BeginTime: TDateTime;
ILoop jLoop: Integer;
The begin
BeginTime:=Now;
With ClientDataSet1 do
The begin
DisableControls;//to cut off the ClientDataSet associated with control of
For iLoop:=0 to 3000 do
The begin
Append.
For jLoop:=1 to 60 do
The begin
FieldByName (' Field '+ IntToStr (jLoop)). The AsString:=' Code '+ IntToStr (iLoop);
The end;
The end;
Post;
First;
EnableControls;//restore ClientDataSet associated with control of
The end;
Edit1. Text:=FormatDateTime (' hh: nn: ss. ZZZ, Now - BeginTime);

BeginTime:=Now;
ListView1. Items. The Count:=3000;
Edit3. Text:=FormatDateTime (' hh: nn: ss. ZZZ, Now - BeginTime);
The end;

CodePudding user response:

reference 4 floor BlueStorm response:
the last post is not already solved the DBGrid performance issues? Was 3000 rows and three columns of data, it only took 0.012 seconds, I had a test today, even 60 columns, also only 0.25 seconds, your computer or network is slow?


DBGrid and still want to ask, do you have a similar to the ListView OnData implementation approach, after all, a few times you test 60 column, 0.25 seconds and OnData0.02 also have more than ten times the speed of the gap

CodePudding user response:

May be a Delphi version is too old, can't use the new version?

CodePudding user response:

refer to the eighth floor BlueStorm response:
may be Delphi version is too old, can't use the new version?


Version does not upgrade, after all, company a unified development environment, is not literally can change
TFDMemTable cannot be used actually problem also is not very big, 0.25 second way also can actually accept
But don't know how to implement the code to trouble great god provides the code to see my code to buy it, is to 2 seconds

CodePudding user response:

It is similar to the above code you provide

CodePudding user response:


 
Type
TForm1=class (TForm)
For: TButton;
DataSource1: TDataSource;
Edit1: TEdit;
Time: TLabel;
DBGrid1: TDBGridEh;
ClientDataSet1: the TClientDataSet;
Procedure Button1Click (Sender: TObject);
Procedure FormCreate (Sender: TObject);
Private

Public
{Public declarations}
The end;

Var
Form1: TForm1;

Implementation

{$R *. DFM}

Procedure TForm1. FormCreate (Sender: TObject);
Var
I: Integer;
S: a String;
The begin
With ClientDataSet1. FieldDefs do
The begin
For I:=1 to 20 do
The begin
S:=IntToStr (I);
Add (' Code '+ S, ftString, 8).
Add (' Name '+ S, ftString, 20).
Add (' Number '+ S, ftInteger);
The end;
The end;
DataSource1. The DataSet:=ClientDataSet1;
DBGrid1. The DataSource:=DataSource1;
The end;

procedure TForm1.Button1Click(Sender: TObject);
Var
BeginTime: TDateTime;
I, J: Integer;
S: a String;
The begin
BeginTime:=Now;
With ClientDataSet1 do
The begin
DisableControls;
The Close;
CreateDataSet;
The Open;
LogChanges:=False;
For I:=1 to 3000 do
The begin
Append.
For J:=1 to 20 do
The begin
S:=IntToStr (J);
FieldByName (' Code '+ S) AsString:=' Code '+ intToStr (I);
FieldByName (' Name '+ S) AsString:=' Name '+ intToStr (I);
FieldByName (' Number '+ S) AsInteger:=I;
The end;
Post;
The end;
EnableControls;
The end;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related