如何控制ScrollBox的位置?(50分)

  • 主题发起人 MicroZeng
  • 开始时间
M

MicroZeng

Unregistered / Unconfirmed
GUEST, unregistred user!
Delphi 中, 我要ScrollBox的滚动条不出现, 而用Button1来控制其位置
的滚动.请问怎么做?
 
TScrollBox中有下面幾個Methods可用:

*ScrollInView(AControl: TControl)
用來將位置調到AControl可見範圍
AControl是位於ScrollBox中的物件

*ScrollBy(DeltaX, DeltaY: Integer)
用來做ScrollBox中的可見視野旳位移調整
 
同意FlyFantasy的看法,你可以直接参考联机帮助中有关
ScrollBy方法的信息,如下:


ScrollBy scrolls the contents of a windowed control.

procedure ScrollBy(DeltaX, DeltaY: Integer);

Description

Call ScrollBy to scroll the contents within the control. While ScrollBy can be used for any windowed control, it makes the most sense to use it for descendents of TScrollingWinControl.
Applications seldom need to call the ScrollBy method unless they implement their own scrolling interface rather than relying on a scroll bar.
The DeltaX parameter is the change in pixels along the X axis. A positive DeltaX value scrolls the contents to the right; a negative value scrolls the contents to the left. The DeltaY parameter is the change in pixels along the Y axis. A positive DeltaY value scrolls the contents down; a negative value scrolls the contents up.
 
问题解决了,感谢FlyFantasy & yanghaijun两位大虾的帮忙!
我还有一个问题,请两位继续帮忙!
:如何取得一个窗体内所有构件的名称,是什么构件?
 
比較容易的方法是利用每個TComonent類別之後都有一些屬性可用
#Components: Owner屬於此物件的物件陣列
#ComponentCount: Owner屬於此物件的物件總數
#ClassName: 類別名稱
#Name: 元件名稱

例: 下面的程式會把Form1上的所有物件列在ListBox1上頭
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
for I := 0 to ComponentCount - 1 do
begin
ListBox1.Items.Add(Components.ClassName +
' ' + Components.Name);
end;
end;
 
多人接受答案了。
 
顶部