一个listView在Report形式下,我在网格中画了一个ComboBox。
如何拉动ListView的ScrollBar
使这个ComboBox跟着移动。
最好有源代码!谢谢!

解决方案 »

  1.   

    很奇怪,这个问题在CSDN上挂了有一会儿了
    procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
    begin
      ComboBox1.Top:=ListView1.Items[4].Top;
    end;
      

  2.   

    to li_zhifu(东北人)
    这段代码为何不画combobox
    procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
    begin
      if State=[cdsSelected] then
        ComboBox1.Top:=ListView1.Items[4].Top;
    end;我是在ItemSelect里做的,但无法控制ScrollBar的事件,
      

  3.   

    下面是程序代码,也请各位帮忙解决一下
    WMVScroll和WMHSCroll截获的只是窗体的ScrollBar的消息,listview的WM_VSROLL和
    WM_HSROLL根本就截获不到,如何才能截获到ListView的这两个消息。Application.onMessage
    也不能截获,最好有源代码,谢谢
    ......
      private
        { Private declarations }
        procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
        procedure WMHSCroll(var Message: TWMHSCroll); message WM_HSCROLL;
        procedure AppMessage(var Msg: TMsg; var Handled: Boolean);
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean);
    begin
      {if Msg.message = WM_VSCROLL then
      begin
        {重画代码}
      end;}
    end;procedure TForm1.WMHSCroll(var Message:TWMHSCroll);
    begin
      {重画代码}
      Inherited;
    end;procedure TForm1.WMVScroll(var Message: TWMVScroll);
    begin
      {重画代码}
      Inherited;
    end;procedure TForm1.lvSelectItem(Sender: TObject; Item: TListItem;
      Selected: Boolean);
    var
      r: TRect;
    begin
      if lv.Tag<>item.Index then
        begin
          r:=Item.DisplayRect(drBounds);
          cmb.Parent:=LV;
          cmb.Left:=r.Left+lv.Columns[0].Width+2;
          cmb.Top:=r.Top;
          cmb.Width:=lv.Columns[1].Width+2;
          cmb.Text:=item.SubItems[0];
          Caption:=caption+';'+IntToStr(Item.Index);
          Lv.Tag:=Item.Index;
        end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      //Application.OnMessage:=AppMessage;
    end;
      

  4.   

    TListView自己有checkbox的选择框吧,问什么还要画?