Solved

Scrolling a ScrollBox

Posted on 1998-09-16
15
521 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Title # Comments Views Activity
Strange behavior when a form is closed 6 69
Delphi Yen format 3 62
update joined tables 2 64
migrate this code to work on android 1 32
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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 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