• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

The TDBGRID is moved when get all new record from TTable ?

Dear Advisor !


I use Delphi 5.0

TDBGRID is moved (be wriggled), when i retrieve new data from Table.

I also used InputForm.OrderTable.DisableConTrol. But it is not effcted.

Thanks for all
0
NamCit
Asked:
NamCit
  • 6
  • 2
  • 2
  • +1
1 Solution
 
marcoszorrillaCommented:
Here your are an example, and works fine.
Best Regards.
Marcos.


         try
         DmNv.Ven.Disablecontrols;

          While not DmNv.Ven.EOF do
          begin
          nUnis:=nUnis + DmNv.Venunidades.Value;
          nImporte:=nImporte + DmNv.VENIMPORTE.Value;
          nComision:= nComision + DmNv.VENTTLCOMIS.Value;
          DmNv.Ven.Next;
          end;

          Finally
          DmNv.Ven.Enablecontrols;
0
 
NamCitAuthor Commented:

Dear !

"Moved" is meant "to be shaked"

There is no error for the customer. But i want the TDBGRID to be shake a little so that.

My code (after adding your comment) :

   DataQuery := HopDongForm.Query ;
           With DataQuery Do
           BeGin
            Active := False     ;
            SQL.Clear           ;
            SQL.Add('select a.*, b.tendv  from cthopdong a')    ;
            SQL.Add('left outer join dmdv b on a.madv = b.madv');
            SQL.Add('where sohd = :sohd')               ;
            Parameters.ParamValues['sohd'] := lcsohd    ;
            Open   ;
            First  ;

            DataControl := HopDongForm.DetailTable ;
      try
            DataControl.DisableControls ;

            While not Eof do
            Begin
               DataControl.Append ;
               DataControl.FieldByName('madv').AsString      := FieldByName('madv').AsSTring    ;
               DataControl.FieldByName('tendv').AsString     := FieldByName('tendv').AsString   ;
               DataControl.FieldByName('matt').AsString      := FieldByName('matt').AsString    ;
               DataControl.FieldByName('tienvn').AsInteger   := FieldByName('tienvn').AsInteger ;
               DataControl.FieldByName('diengiai').AsString  := FieldByName('diengiai').AsString ;

               Next    ;
            End ;
            DaTaControl.First ;
         Finally ;
            DataControl.EnableControls ;
         end ;
           End ;
0
 
NamCitAuthor Commented:

Still not effected
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
NamCitAuthor Commented:

What should i do next ?

I dont want TDBGRID to be "alive" when updating data .

Addtion, before insert new record, i delete all old record
0
 
kretzschmarCommented:
?
add a order by clause
0
 
NamCitAuthor Commented:

Please show me clearly
0
 
marcoszorrillaCommented:
Try setting DoubleBuffered to True.
Best Regards.
Marcos.
0
 
NamCitAuthor Commented:

Dear Marcoszorrilla  !

I just set OrderForm.DoubleBuffered to True. But not effected.



0
 
geobulCommented:
Delete the old records immediately after DataControl.DisableControls. Perhaps deleting shakes your grid.

Regards, Geo
0
 
NamCitAuthor Commented:

Yes, before updating new data, i should delete old data.

That makes TDBGrid "alive"
0
 
geobulCommented:
Did that solve the problem? For example:

DataControl.DisableControls ;
try
  // delete old records
  DataControl.Last;
  for i := DataControl.RecordCount downto 1 do
    DataControl.Delete;

  // add new records
  While not Eof do
  Begin
    DataControl.Append ;
    DataControl.FieldByName('madv').AsString      := FieldByName('madv').AsSTring    ;
    DataControl.FieldByName('tendv').AsString     := FieldByName('tendv').AsString   ;
    DataControl.FieldByName('matt').AsString      := FieldByName('matt').AsString    ;
    DataControl.FieldByName('tienvn').AsInteger   := FieldByName('tienvn').AsInteger ;
    DataControl.FieldByName('diengiai').AsString  := FieldByName('diengiai').AsString ;
    DataControl.Post; // post changes here
    Next    ;
  End ;
  DaTaControl.First ;
Finally ;
  DataControl.EnableControls ;
end ;

Regards, Geo
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now