控件太多的问题

XXKKFF 2011-12-25 06:44:46
动态添加的控件太多, 显示不完,
我想把控件的parent设成一个scrollbox, 控件显示不完的时候自动出现滚动条, 要怎么设置?
...全文
255 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
虾猫先生 2011-12-30
  • 打赏
  • 举报
回复
这个行
[Quote=引用 15 楼 warrially 的回复:]

imgCandidates[ind].Anchors := [akLeft] + [akTop] + [akRight] + [akBottom];


这个没用啊。。。你这代码。。。 没意义

还不如这样

Delphi(Pascal) code
imgCandidates[ind].align := alClient;
[/Quote]
mayyang 2011-12-30
  • 打赏
  • 举报
回复
不好意思,网络不好,多发了
mayyang 2011-12-28
  • 打赏
  • 举报
回复
function TFrmMain.createimage(left, top: integer;
imagename: string): TImage;
var
img : TImage;
pic : TPicture;
begin
try
img := TImage.Create(ScrollBox2);
pic := TPicture.Create;
pic.LoadFromFile(ExtractFilePath(Application.ExeName) + imagename);
img.Parent := ScrollBox2;
//绑定图片
img.Picture := pic;
img.Height := pic.Height;
img.Width := pic.Width;
img.Left := left;
img.Top := top;
result := img;
finally
FreeAndNil(pic);
end;
end;
爱蹄子的羊头 2011-12-28
  • 打赏
  • 举报
回复
imgCandidates[ind].Anchors := [akLeft] + [akTop] + [akRight] + [akBottom];


这个没用啊。。。你这代码。。。 没意义

还不如这样

imgCandidates[ind].align := alClient;
mayyang 2011-12-28
  • 打赏
  • 举报
回复
function TFrmMain.createimage(left, top: integer;
imagename: string): TImage;
var
img : TImage;
pic : TPicture;
begin
try
img := TImage.Create(ScrollBox2);
pic := TPicture.Create;
pic.LoadFromFile(ExtractFilePath(Application.ExeName) + imagename);
img.Parent := ScrollBox2;
//绑定图片
img.Picture := pic;
img.Height := pic.Height;
img.Width := pic.Width;
img.Left := left;
img.Top := top;
img.ShowHint := false;
img.Hint := '-';
result := img;
finally
FreeAndNil(pic);
end;
end;
mayyang 2011-12-28
  • 打赏
  • 举报
回复
function TFrmMain.createimage(left, top: integer;
imagename: string): TImage;
var
img : TImage;
pic : TPicture;
begin
try
img := TImage.Create(ScrollBox2);
pic := TPicture.Create;
pic.LoadFromFile(ExtractFilePath(Application.ExeName) + imagename);
img.Parent := ScrollBox2;
//绑定图片
img.Picture := pic;
img.Height := pic.Height;
img.Width := pic.Width;
img.Left := left;
img.Top := top;
result := img;
finally
FreeAndNil(pic);
end;
end;
无语孩童 2011-12-27
  • 打赏
  • 举报
回复
把scrollbox的autoscroll属性设置成true,scrollbox就可以自动出现滚动条了。
formernetcn 2011-12-27
  • 打赏
  • 举报
回复
把scrollbox的autoscroll属性设置成true,scrollbox就可以自动出现滚动条了。
sunli_py 2011-12-27
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 mayyang 的回复:]

把scrollbox的autoscroll属性设置成true,scrollbox就可以自动出现滚动条了。
[/Quote]
就这个
kevin_wzh 2011-12-26
  • 打赏
  • 举报
回复
按照楼上的办
mayyang 2011-12-26
  • 打赏
  • 举报
回复
把scrollbox的autoscroll属性设置成true,scrollbox就可以自动出现滚动条了。
mayyang 2011-12-26
  • 打赏
  • 举报
回复
拿label来说:
lbl := tlabel.create(scrollbox1);
lbl.parent := scrollbox1;
//设置lbl控件在scrollbox1中的位置,left和top都是相对srollbox1的边界
lbl.left := 0;
lbl.top := 0;
hongss 2011-12-26
  • 打赏
  • 举报
回复
动态创建其实跟你直接放置差不多,都要考虑位置、大小
sxbug 2011-12-26
  • 打赏
  • 举报
回复
布局一下

控制好大小及位置
XXKKFF 2011-12-26
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 xxkkff 的回复:]

引用 5 楼 mayyang 的回复:

拿label来说:
lbl := tlabel.create(scrollbox1);
lbl.parent := scrollbox1;
//设置lbl控件在scrollbox1中的位置,left和top都是相对srollbox1的边界
lbl.left := 0;
lbl.top := 0;


还是不行啊
我要放的控件是TIm……
[/Quote]

imgCandidates[ind].Stretch := true;
imgCandidates[ind].Anchors := [akLeft] + [akTop] + [akRight] + [akBottom];
两行去掉就可以了, 为什么呢?
XXKKFF 2011-12-26
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 mayyang 的回复:]

拿label来说:
lbl := tlabel.create(scrollbox1);
lbl.parent := scrollbox1;
//设置lbl控件在scrollbox1中的位置,left和top都是相对srollbox1的边界
lbl.left := 0;
lbl.top := 0;
[/Quote]

还是不行啊
我要放的控件是TImage, 它的属性要不要怎么设置一下?
我设的是
imgCandidates[ind] := TImage.Create(scrlbxLuckydogs1);
imgCandidates[ind].Parent := scrlbxLuckydogs1;
imgCandidates[ind].Width := 1;
imgCandidates[ind].Height := 1;
imgCandidates[ind].Visible := True;
imgCandidates[ind].Proportional := true;
imgCandidates[ind].Stretch := true;
imgCandidates[ind].Anchors := [akLeft] + [akTop] + [akRight] + [akBottom];
都先生 2011-12-25
  • 打赏
  • 举报
回复
同意楼上的哦
whisht 2011-12-25
  • 打赏
  • 举报
回复
创建控件时parent设置为scrollbox控件

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧