469,290 Members | 1,882 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,290 developers. It's quick & easy.

Scrolling Text in VB.NET Window Form

I need to have a "scrolling" text label or textbox at the bottom of my
window to show the URL of where a song is being played from. I want the
text to scroll on a single line from left to right in case the URL is longer
than the width of the textbox/text label.

Is there a native way to do this in VB.NET?

Nov 21 '05 #1
5 21279
Use a panel and set the autoscroll to true.

"Will Gillen" <gi******@nsuok.edu> wrote in message
news:e2**************@TK2MSFTNGP11.phx.gbl:
I need to have a "scrolling" text label or textbox at the bottom of my
window to show the URL of where a song is being played from. I want the
text to scroll on a single line from left to right in case the URL is
longer
than the width of the textbox/text label.

Is there a native way to do this in VB.NET?


Nov 21 '05 #2
Hi Will,

One technique is to use a Timer control and in its Tick handler manipulate a
string to create a scrolling effect e.g.

Private _NowPlaying As String = "This test will get scrolled."
Private Sub NowPlayingTimer_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles NowPlayingTimer.Tick
_NowPlaying = _NowPlaying.Substring(_NowPlaying.Length - 1, 1) &
_NowPlaying.Substring(0, _NowPlaying.Length - 1)
NowPlayingLabel.Text = _NowPlaying
End Sub

_NowPlaying is a String variable declared at the class level (a class member
field) that holds the string currently being displayed in a label named
NowPlayingLabel.

Each time the Timer's Tick event is handled the _NowPlaying string is
changed by pulling a character off one end of the string and placing at the
other end of the string.

_NowPlaying = _NowPlaying.Substring(_NowPlaying.Length - 1, 1) &
_NowPlaying.Substring(0, _NowPlaying.Length - 1)

After the modification the NowPlayLabel.Text is updated with the
modification.

NowPlayingLabel.Text = _NowPlaying

The end result is a scrolling text effect in the NowPlayingLabel.

Setting the Timer's Interval to 200 produces a nice scroll effect.

--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
"Will Gillen" <gi******@nsuok.edu> wrote in message
news:e2**************@TK2MSFTNGP11.phx.gbl...
I need to have a "scrolling" text label or textbox at the bottom of my
window to show the URL of where a song is being played from. I want the
text to scroll on a single line from left to right in case the URL is
longer
than the width of the textbox/text label.

Is there a native way to do this in VB.NET?

Nov 21 '05 #3
After seeing scorpian's answer I realized I did not read your question
carefully enough - please ignore my answer.
--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
"Mike McIntyre" <mi****@dotnetshowandtell.com> wrote in message
news:ek**************@TK2MSFTNGP12.phx.gbl...
Hi Will,

One technique is to use a Timer control and in its Tick handler manipulate
a string to create a scrolling effect e.g.

Private _NowPlaying As String = "This test will get scrolled."
Private Sub NowPlayingTimer_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles NowPlayingTimer.Tick
_NowPlaying = _NowPlaying.Substring(_NowPlaying.Length - 1, 1) &
_NowPlaying.Substring(0, _NowPlaying.Length - 1)
NowPlayingLabel.Text = _NowPlaying
End Sub

_NowPlaying is a String variable declared at the class level (a class
member field) that holds the string currently being displayed in a label
named NowPlayingLabel.

Each time the Timer's Tick event is handled the _NowPlaying string is
changed by pulling a character off one end of the string and placing at
the other end of the string.

_NowPlaying = _NowPlaying.Substring(_NowPlaying.Length - 1, 1) &
_NowPlaying.Substring(0, _NowPlaying.Length - 1)

After the modification the NowPlayLabel.Text is updated with the
modification.

NowPlayingLabel.Text = _NowPlaying

The end result is a scrolling text effect in the NowPlayingLabel.

Setting the Timer's Interval to 200 produces a nice scroll effect.

--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
"Will Gillen" <gi******@nsuok.edu> wrote in message
news:e2**************@TK2MSFTNGP11.phx.gbl...
I need to have a "scrolling" text label or textbox at the bottom of my
window to show the URL of where a song is being played from. I want the
text to scroll on a single line from left to right in case the URL is
longer
than the width of the textbox/text label.

Is there a native way to do this in VB.NET?


Nov 21 '05 #4
Actually you were right on, it was me who did not phrase correctly.
Your answer was what I was looking for....

I tried your approach, and it does work, however, it is still a little
"jerky". I had thought about doing it that way, but was thinking there may
be something more "smooth" for the scrolling text... kind of like a
scrolling marquee in HTML...

I'll keep looking... If anyone knows of some control that does this, please
let me know. Thanks.


"Mike McIntyre" <mi****@dotnetshowandtell.com> wrote in message
news:ek**************@TK2MSFTNGP12.phx.gbl...
Hi Will,

One technique is to use a Timer control and in its Tick handler manipulate a string to create a scrolling effect e.g.

Private _NowPlaying As String = "This test will get scrolled."
Private Sub NowPlayingTimer_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles NowPlayingTimer.Tick
_NowPlaying = _NowPlaying.Substring(_NowPlaying.Length - 1, 1) &
_NowPlaying.Substring(0, _NowPlaying.Length - 1)
NowPlayingLabel.Text = _NowPlaying
End Sub

_NowPlaying is a String variable declared at the class level (a class member field) that holds the string currently being displayed in a label named
NowPlayingLabel.

Each time the Timer's Tick event is handled the _NowPlaying string is
changed by pulling a character off one end of the string and placing at the other end of the string.

_NowPlaying = _NowPlaying.Substring(_NowPlaying.Length - 1, 1) &
_NowPlaying.Substring(0, _NowPlaying.Length - 1)

After the modification the NowPlayLabel.Text is updated with the
modification.

NowPlayingLabel.Text = _NowPlaying

The end result is a scrolling text effect in the NowPlayingLabel.

Setting the Timer's Interval to 200 produces a nice scroll effect.

--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
"Will Gillen" <gi******@nsuok.edu> wrote in message
news:e2**************@TK2MSFTNGP11.phx.gbl...
I need to have a "scrolling" text label or textbox at the bottom of my
window to show the URL of where a song is being played from. I want the
text to scroll on a single line from left to right in case the URL is
longer
than the width of the textbox/text label.

Is there a native way to do this in VB.NET?


Nov 21 '05 #5
Well, I found a good example at DevCity:
http://www.devcity.net/forums/topic.asp?tid=78584

This is exactly what I was looking for...

"Will Gillen" <gi******@nsuok.edu> wrote in message
news:e2**************@TK2MSFTNGP11.phx.gbl...
I need to have a "scrolling" text label or textbox at the bottom of my
window to show the URL of where a song is being played from. I want the
text to scroll on a single line from left to right in case the URL is longer than the width of the textbox/text label.

Is there a native way to do this in VB.NET?

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Midas NDT Sales | last post: by
3 posts views Thread by Vikram Bhatia | last post: by
2 posts views Thread by James CC | last post: by
4 posts views Thread by Keith Bentrup | last post: by
3 posts views Thread by Chamnap | last post: by
11 posts views Thread by =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.