Solved

Scrolling a ScrollBox

Posted on 1998-09-16
15
519 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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