本人在ListView里边自己添加控件,但是当旁边滚动条滚动时,控件位置不随之变化(急)
While not Eof do
begin
ListItem := ListView2.Items.Add;
ListItem.Caption := FieldbyName('OPT_MEan').AsString;
ListItem.SubItems.Add('');
r := Listview2.Items[RowIndex].DisplayRect(drBounds);
r.Left := r.Left + Listview2.columns[0].Width;
r.Right := r.Left + Listview2.columns[1].Width;
FcheckBox[RowIndex] := TCheckbox.Create(Self);
FcheckBox[RowIndex].Height :=20;
FcheckBox[RowIndex].Parent := Listview2;
FcheckBox[RowIndex].BoundsRect := r;
FcheckBox[RowIndex].Caption := Inttostr(FcheckBox[RowIndex].Top);
RowIndex := RowIndex +1;
Next;
end;
代码很简单,问题是listView的滚动条滚动时,checkbox的位置不会发生变化,请高手帮忙