Solved

Scrolling a ScrollBox

Posted on 1998-09-16
15
512 Views
Last Modified: 2010-04-06
Hi!  Real easy one (I hope).  How do you get a scrollbox to scroll down as items are added to it?  Im adding dynamically labels to a ScrollBox and want the scrollbox to move down as each one is added.

Are the labels automatically destroyed when the ScrollBox is?

Thanks!!

Stu.
0
Comment
Question by:Stuart_Johnson
  • 5
  • 5
  • 5
15 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 20 total points
ID: 1339986
you will have to use the ScrollInView method of the Scrollbox

ie:

  ScrollBox1.ScrollInView( Label1 ) ;

and so long as the label has the scrollbox as its parent, then yes, it should be destroyed...

Tim
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339987
Actually you can use  ScrollBy() method,...

Regards,
Viktor Ivanov
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1339988
Hi Tim,

Thanks for the quick response.  How do I get the Controls name if Im adding dynamically?

Heres a snippet:

   With TLabel.Create(Application) do begin
      Parent := sbData;
      AutoSize := True;
      WordWrap := True;
      Caption := eSItem.Text;
      Font.Color := clRed;
      Top := sbData.ControlCount*Height;
   End;

Thanks mate,


Stu.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339989
TComponent(Sender).Name;

Regards,
Viktor Ivanov
0
 
LVL 35

Expert Comment

by:TimYates
ID: 1339990
Have you tried :

var
  b : tLabel ;
begin

//...

  b := tLabel.Create( Application ) ;
   With b do begin
      Parent := sbData;
      AutoSize := True;
      WordWrap := True;
      Caption := eSItem.Text;
      Font.Color := clRed;
      Top := sbData.ControlCount*Height;
   End;

  Then its name is "b" ?

  If this doesnt work, I'll try to come up with something cleverer...heh...

  Cheers,

  Tim.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 1339991
Heh, logged on at the same time as viktornet...

we seem to be competing for fastest answers...

*grin*

Tim.
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1339992
(Edited by Computer101), that'll do!  I didnt even think of that :)  DUH!  

Just a sec.

viktornet:

TComponent(Sender).Name = Button1

Its telling me the senders name, not the name of the new component).

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 35

Expert Comment

by:TimYates
ID: 1339993
*comfort*
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1339994
I had a minor problem with it setting the height of the newly added labels once the scollbox started scrolling.  Heres what I came up with:

   lNewLabel := TLabel.Create(Application);
   With lNewLabel do begin
      Parent := sbData;
      AutoSize := True;
      WordWrap := True;
      Caption := eSItem.Text;
      Font.Color := clRed;
      Top := (sbData.ControlCount*Height)-sbData.VertScrollBar.Position;
   End;

'ken fantastic regardless..

Ta all.

Stu.

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339995
Hello guys.....Didn't get what you mean.....

Don't mean to be sarcastic but the way Tim showed is the best way to create objects....I read it somewhere on the net...

Regards,
Viktor Ivanov
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1339996
Oh, and the sbData.ScrollInView(lNewLabel) of cause :)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 1339997
Thanls Viktor :) (and good night)
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339998
Good night to y'all ;-)

Regards,
Viktor Ivanov
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1339999
Thanks for your help Viktor.  Its always nice to have different things to try.

Good Night !

Stuart.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1340000
Good night!

Regards,
Viktor Ivanov
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now