Solved

Scrolling a ScrollBox

Posted on 1998-09-16
15
517 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Working this component WebCopy with proxy, help 3 84
FMX StringGrid1->Canvas->FillRect Problem 3 150
SUM 2 INTEGER ARRAYS INTO 1 10 100
Tvertscrollbox like a whatsapp layout 5 27
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

776 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