Text on a form help

gazeranco

Well-known member
Joined
Feb 11, 2006
Messages
45
Location
Englandshire!
Programming Experience
Beginner
Hello,

I asked a question about scrolling text but i placed it in the wrong forum, so here it is again :)

How do i make the text of a label or a linklabel scroll accross the form?

Could anyone provide a code example?

Thanks! :eek:
 
Do you mean something like the attached file?
What I did was place a timer that:
a: moves the linklabel to the left by 10 px
b: checks if the label is off the visible area of the form, if so places it to the beginning again

If this is not what you need please give more info

HTH
 

Attachments

  • WindowsApplication1.zip
    22.4 KB · Views: 28
Hello again all,

I am having problems with this, the code example works perfect, i adjust the code to contain the name of my linklabel on the form and it doesn't work, so i then put a new linklabel on with the default name (same as the example) and it still doesnt work, all my syntax is right no code has any problems no build errors etc... does anyone know what the issue could be?

Im thinking maybe it is this bit

If LinkLabel1.Left <= (Me.Left - (2 * LinkLabel1.Width)) Then

From what i can see that is checking if something is true? but i don't know what....


 
Here is all the code if it helps....

Public
Class Form1
Inherits System.Windows.Forms.Form
Dim link As String = ""
Dim myrssurl As String = ""
Public Sub RefreshFeedsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshFeedsToolStripMenuItem.Click
Dim rssURL As String = (myrssurl)
Dim myRequest As System.Net.WebRequest = System.Net.WebRequest.Create(rssURL)
Dim myResponse As System.Net.WebResponse = myRequest.GetResponse()
Dim rssStream As System.IO.Stream = myResponse.GetResponseStream()
Dim rssDoc As System.Xml.XmlDocument = New System.Xml.XmlDocument()
rssDoc.Load(rssStream)
Dim rssItems As System.Xml.XmlNodeList = rssDoc.SelectNodes("rss/channel/item")
Dim title As String = ""
'Dim link As String = ""
Dim description As String = ""
Dim currentRssItem As System.Xml.XmlNode
For Each currentRssItem In rssItems
Dim rssDetail As System.Xml.XmlNode
' TITLE
rssDetail = currentRssItem.SelectSingleNode("title")
If Not IsNothing(rssDetail) Then
title = rssDetail.InnerText
Else
title = ""
End If
' LINK
rssDetail = currentRssItem.SelectSingleNode("link")
If Not IsNothing(rssDetail) Then
link = rssDetail.InnerText
Else
link = ""
End If

' DESCRIPTION
rssDetail = currentRssItem.SelectSingleNode("description")
If Not IsNothing(rssDetail) Then
description = rssDetail.InnerText
Else
description = ""
End If
LinkLabelRss.Text = (title)
Next
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
Public Sub LinkLabelRss_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabelRss.LinkClicked
System.Diagnostics.Process.Start(link)
End Sub
Private Sub BBCNewsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BBCNewsToolStripMenuItem.Click
myrssurl =
"http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml"
End Sub
Private Sub BBCSportToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BBCSportToolStripMenuItem.Click
myrssurl =
"http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/front_page/rss.xml"
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If LinkLabel1.Left <= (Me.Left - (2 * LinkLabel1.Width)) Then
LinkLabel1.Left = Me.Width
End If
LinkLabel1.Left -= 10
End Sub
End
Class
 
If the name of the linklabel is no longer linklabel1 you will have to change it to what it is now called, same goes with the timer and any other properties

I don't mean to be patronising, if you dont understand the name of components, it is what is shown in the properties box under name

Regards
 
If LinkLabel1.Left <= (Me.Left - (2 * LinkLabel1.Width)) Then

this code checks if the label is further than the left hand side of the form

---

Also had another idea for this you might want to use. When the mouse is hovering over a certain linklabel it will stop scrolling, when you move the mouse away again it will continue scrolling.

If you would like to use this idea, it could be done like so:
VB.NET:
    Private Sub LinkLabel1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkLabel1.MouseEnter
        Timer1.Stop()
    End Sub

    Private Sub LinkLabel1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkLabel1.MouseLeave
        Timer1.Start()
    End Sub
 
Hi Craig,

Thanks for all your replies, I guess I was just tired, I did not set the timer enabled property to True - I guess its default is false and i overlooked it...

How dumb do i feel lol, never mind!

Thanks Again!
 
Back
Top