请教ProgressBar1的用法,与哪些控件结合起来用,注意的问题?请代码提示。谢谢!

解决方案 »

  1.   


    ...
    给个例子unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ComCtrls;type
      TForm1 = class(TForm)
        ListView1: TListView;
        ProgressBar1: TProgressBar;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      i: integer;
      NewItem: TListItem;
    begin
      for i := 0 to 99 do
      begin
        NewItem := ListView1.Items.Add;
        NewItem.Caption := 'aaa';
        ProgressBar1.Position := i;
      end;
    end;end.
      

  2.   

    谢谢luke5678(奇异) 。
    请问如果我要向数据库中插入或更新(Query)数据时,怎样表示她的进度?
      

  3.   

    思路是一样的啊eg:插100条记录:for i := 0 to 99 do
    begin
      ...
      Query1.SQL.Add('insert into ...');
      ProgressBar1.Position := i;
    end;
      

  4.   

    function TForm1.UpdateList_Rcyk: Boolean;
    begin
      Result:=False;
      with Qy_Update do
      begin
        Close;
        SQL.Clear;
        SQL.Add('update JxList_Rcyk                         ');
        SQL.Add('set Yj_Yjj=Yj_Yjj+Wj_Yjj,Yj_Fy=Yj_Fy+Wj_Fy ');
        SQL.Add(',Wj_Yjj=0,Wj_Fy=0                          ');
        SQL.Add('where (time_cy is not null or time_cy<>0)  ');
        SQL.Add('and code_Jzzt=''0''                        ');
        SQL.Add('and (Yj_Yjj is null or Yj_Yjj=0)           ');
        ExecSQL;
        Result:=True;
        Close
      end;
    end;
    代码如上,如何实现?
      

  5.   

    我觉得没必要用ProgressBar
    这个过程很慢吗?
      

  6.   

    不慢,但是要让用户知道他做完了这件事,当然完了来个提示也可以,这样就增加了用户的按键次数,不如用ProgressBar直观。
      

  7.   

    但是要让用户知道他做完了这件事----------------------------------就这个目的可以这样:(^_^)
    function TForm1.UpdateList_Rcyk: Boolean;
    begin
      Result:=False;
      with Qy_Update do
      begin
        Close;
        SQL.Clear;
        SQL.Add('update JxList_Rcyk                         ');
        SQL.Add('set Yj_Yjj=Yj_Yjj+Wj_Yjj,Yj_Fy=Yj_Fy+Wj_Fy ');
        SQL.Add(',Wj_Yjj=0,Wj_Fy=0                          ');
        SQL.Add('where (time_cy is not null or time_cy<>0)  ');
        SQL.Add('and code_Jzzt=''0''                        ');
        SQL.Add('and (Yj_Yjj is null or Yj_Yjj=0)           ');
        ExecSQL;
        ProgressBar1.Position := 100;
        Result:=True;
        Close
      end;
    end;