当动态写数据到一定量的时候,listbox会出现垂直滚动条,如何可以不显示?

解决方案 »

  1.   

    一个FORM,一个BUTTON,一个BUTTON点击事件,然后COPY我的代码替换unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TMyListBox = class(TListBox)
      protected
        procedure CreateParams(var Params: TCreateParams); override;
      end;  TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TMyListBox.CreateParams(var Params: TCreateParams);
    begin
      inherited CreateParams(Params);
      with Params do
      begin
        Style := Style - WS_VSCROLL;
      end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      i: integer;
      lb: TMyListBox;
    begin
      lb:= TMyListBox.Create(Self);
      lb.Parent:= Self;
      lb.SetBounds(10,10,100,100);
      for i:= 0 to 100 do
        lb.Items.Add(inttostr(i))
    end;end.
      

  2.   

    正解
      也可以直接发消息  设置  ListView 的 sytle
      

  3.   

    设置listbox的 列数 大于0,则变为左右的滚动条
      

  4.   


    procedure TForm1.FormCreate(Sender: TObject);
    begin
    SetWindowLong(ListBox1.Handle,GWL_STYLE,GetWindowLong(ListBox1.Handle,GWL_STYLE) and  not WS_VSCROLL and not WS_HSCROLL);
    end;
      

  5.   

    SetWindowLong 我之前已试过了,不行的. 即焦点在LISTBOX1上面时,一直按向下键,超过显示行数后就会显示滚动条.
      

  6.   

    用一个panl把滚动条盖住。。哈哈。。楼主不要打人
      

  7.   

    panel
      

  8.   

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    SetWindowLong(ListBox1.Handle,GWL_STYLE,GetWindowLong(ListBox1.Handle,GWL_STYLE) and  not WS_VSCROLL and not WS_HSCROLL);
    end;
    其实这个方法是对的。。只是需要多次调用的。。因为LISTBOX的流动条的显示与否是系统动态进行设置的。。
    你要再每次重画之前把滚动条用这个方法隐藏条。