-
[RESOLVED] [2005] Scrolling Label Text
I have been searching the form for a way to scroll text in a label control kinda like a marquee. I found the following code:
Code:
Static counter As Integer = 0
Dim scrollingText As String = "This is some scrolling text that I want to see"
If counter = scrollingText.Length Then counter = 0
lblPlaying.Text = scrollingText.Substring(counter) & scrollingText & scrollingText & scrollingText
counter += 1
The problem I am having is this is not a clean scroll... It is scrolling character for character on the left side of the label but the right side of label is displaying word by word.
Any idea how to fix this?
-
Re: [2005] Scrolling Label Text
use textbox. i have seen this before.
-
Re: [2005] Scrolling Label Text
try using a textbox. set .readonly to true + .borderstyle to none
-
Re: [2005] Scrolling Label Text
I was trying to stay away from a text box because I need the control to accept a transparent background.
-
Re: [2005] Scrolling Label Text
you won't get a real transparent background with either a label or a textbox
-
Re: [2005] Scrolling Label Text
No that is physically moving the control on the form. I just need to move the text. Reason being is if the text is to long for the label control, I just want to scroll it.
-
Re: [2005] Scrolling Label Text
That is still not clean at all. It scrolls per word, not per character.
-
Re: [2005] Scrolling Label Text
a textbox scrolls how you want it to
-
Re: [2005] Scrolling Label Text
Yeah, I could use a textbox but it does not allow the background to be transparent.
I am NOW working on a control that will allow me to have a marquee, my math appears to be a little off.
Can someone see if they see what is wrong?
Attached is the solution.
EDIT: UPDATED CONTROL BELOW
-
Re: [2005] Scrolling Label Text
Here is my Marquee control. Glad to have this done. Hope this helps someone too.
EDIT: UPDATED CONTROL BELOW
-
Re: [RESOLVED] [2005] Scrolling Label Text
Hi,
Thanks for your control .. can you make the same control but then scroll from right to left? .. or just tell me what i should change..
Thanks in advanced
-
Re: [RESOLVED] [2005] Scrolling Label Text
Here is an updated version that does scroll left to right.
Be sure that you use true type fonts with this control. I have seen some issues with non TTFs.
EDIT: UPDATED CONTROL BELOW
-
Re: [RESOLVED] [2005] Scrolling Label Text
Quote:
Originally Posted by .NetNinja
Here is an updated version that does scroll left to right.
Be sure that you use true type fonts with this control. I have seen some issues with non TTFs.
i thought it had a transparent background?
-
Re: [RESOLVED] [2005] Scrolling Label Text
fast reply .. your original scrolled from left to right .. i need it from right to left
-
Re: [RESOLVED] [2005] Scrolling Label Text
Quote:
Originally Posted by Amien
fast reply .. your original scrolled from left to right .. i need it from right to left
Let me look into making a property for scroll direction.
Quote:
Originally Posted by .paul.
i thought it had a transparent background?
It does have a transparent background if you set the background color to transparent.
-
Re: [RESOLVED] [2005] Scrolling Label Text
thats a transparent background color. i.e. not really transparent, as i told you in post #5:D
-
Re: [RESOLVED] [2005] Scrolling Label Text
Quote:
Originally Posted by .NetNinja
Let me look into making a property for scroll direction.
Thanks ... not to push you or anything .. but if its not too much to ask :)
and can this also be done with the control:
i need to change the MarqueeText right after the last letter is of the screen .. i'm planning on binding Marqueetext to a dynamic xml file
-
Re: [RESOLVED] [2005] Scrolling Label Text
Well, that would take a major add-in for the control to cycle through an array or list of text you want to display. I will look into it though. Might not be to bad to manage.
It will take me a little time also, this control was mainly written for another application I am working on, just give me a little time. Hopefully by tomorrow I will have something put together.
-
Re: [RESOLVED] [2005] Scrolling Label Text
Private Sub loadthenews()
Dim readXML As New XmlTextReader("e:\news.xml")
While readXML.Read()
If readXML.NodeType = XmlNodeType.Text Then
ScrollingMarquee1.MarqueeText += " " & readXML.Value
End If
End While
End Sub
I have this in my app to load the xml text. this loads the text on form_load..
i need to reload the news on the moment that the text cycles .. i could build a timer to reload the text every 10 min ..
-
Re: [RESOLVED] [2005] Scrolling Label Text
is it also possible that, if the text is gone on the right .. that the text appears letter for letter again on the left .. at this moment when the text is gone of the left .. the full text appears again in the scrollbar and then starts scrolling ..
btw .. was this changed in the new version .. cause i thought on the old version the text appeared letter for letter of the left.
-
Re: [RESOLVED] [2005] Scrolling Label Text
sorry for the spam...
would i be possible to build a Thread.Sleep(3000) but that the Text keeps scrolling?
-
Re: [RESOLVED] [2005] Scrolling Label Text
-
Re: [RESOLVED] [2005] Scrolling Label Text
Above the marquee i have a picturebox. that picturebox has a random picture from a certain directory. i want to refresh that picturebox after a few seconds with a new random picture. this while the marquee keeps on running without delay.
-
Re: [RESOLVED] [2005] Scrolling Label Text
Do While UserWantsOut = False
Dim Files() As String = Directory.GetFiles("C:/tmp/")
Dim Gen = New System.Random(My.Computer.Clock.TickCount)
Application.DoEvents()
PictureBox2.Image = Image.FromFile(Files(Gen.Next(1, Files.Length).ToString))
'Label1.Text = Files(Gen.Next(1, Files.Length).ToString)
Loop
For some reason Picturebox2 hangs after a few seconds .. while Label1 keeps on running
-
Re: [RESOLVED] [2005] Scrolling Label Text
For scrolling text you may want to take a look at the link in my signature.
-
Re: [RESOLVED] [2005] Scrolling Label Text
i solved the Thread.Sleep(3000) problem with a Timer2 .. works fine
-
Re: [RESOLVED] [2005] Scrolling Label Text
Attached is the new source code for the Marquee control. It allows you to set which direction you want the text to scroll by setting ScrollLeftToRight to True or False.
EDIT: UPDATED CONTROL BELOW
-
Re: [RESOLVED] [2005] Scrolling Label Text
works fine NetNinja .. Thanks
can you please reponse to #22?
-
Re: [RESOLVED] [2005] Scrolling Label Text
Quote:
Originally Posted by Amien
works fine NetNinja .. Thanks
can you please reponse to #22?
To you answer your question, if I understand correctly, it should be doing that in this version.
-
Re: [RESOLVED] [2005] Scrolling Label Text
when the text is at the end .. the control is cleared completely .. i want to text to scroll completely of the screen .. and then the last letter of the text is of the screen .. then the text should start again on the right side...
thanks so far btw .. great help
-
Re: [RESOLVED] [2005] Scrolling Label Text
What size is the control on your form?
What font are you using?
EDIT:
I have noticed an issue when the font size and/or name is changed. To account for this you might want to modify the calculation (y = -5 * -x) in the tmrMain_Tick subroutine. This will vary on a case by case basis. That is one of the reason I provided this in full source. If a universal solution is found I will post an update to the source.
Note on a variations on the calculation, only the static value (-5) needs to be modified, the variables should remained untouched.
-
Re: [RESOLVED] [2005] Scrolling Label Text
you should write a "Direction" property in it, so it can scroll right to left as well as left to right
-
Re: [RESOLVED] [2005] Scrolling Label Text
Quote:
Originally Posted by .NetNinja
What size is the control on your form?
What font are you using?
EDIT:
I have noticed an issue when the font size and/or name is changed. To account for this you might want to modify the calculation (y = -5 * -x) in the tmrMain_Tick subroutine. This will vary on a case by case basis. That is one of the reason I provided this in full source. If a universal solution is found I will post an update to the source.
Note on a variations on the calculation, only the static value (-5) needs to be modified, the variables should remained untouched.
Thanks .. i'v solved it also by adding a few spaces to the end of ScrollingMarquee1.MarqueeText
-
2 Attachment(s)
Re: [RESOLVED] [2005] Scrolling Label Text
Okay the new version has a property for text direction. Also now all fonts and font sizes work. Also it will scroll like a "true" marquee, and will NOT start at the first few characters of the text.
-
Re: [RESOLVED] [2005] Scrolling Label Text
tested it .. works.. again great job
-
Re: [RESOLVED] [2005] Scrolling Label Text
"Well, that would take a major add-in for the control to cycle through an array or list of text you want to display. I will look into it though. Might not be to bad to manage."
I'v add a timer .. that reads a xml file every x-seconds .. and then updates ScrollingMarquee1.MarqueeText. but the text is not updated and the marquee is getting really slow ..
-
Re: [RESOLVED] [2005] Scrolling Label Text
Do you have any sample code of how you are doing that?
-
Re: [RESOLVED] [2005] Scrolling Label Text
Great control! I think you should post it in the CodeBank!
@jmcilhinney: The scrolling text link in your signature is missing the C# link.
-
Re: [RESOLVED] [2005] Scrolling Label Text
Code:
Timer1.Enabled = True
Timer1.Interval = 5000
5000 is just for testing
Code:
Private Sub LoadTheNews()
Dim readXML As New XmlTextReader("c:/tmp/news.xml")
While readXML.Read()
If readXML.NodeType = XmlNodeType.Text Then
ScrollingMarquee1.MarqueeText += " " & readXML.Value
End If
End While
End Sub
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
LoadTheNews()
End Sub
-
Re: [RESOLVED] [2005] Scrolling Label Text
Its probably getting slow because of:
Code:
ScrollingMarquee1.MarqueeText += " " & readXML.Value
You are never clearing the text, so every 5 seconds the Text gets longer and longer.
Try:
Code:
Private Sub LoadTheNews()
Dim readXML As New XmlTextReader("c:/tmp/news.xml")
ScrollingMarquee1.MarqueeText = ""
While readXML.Read()
If readXML.NodeType = XmlNodeType.Text Then
ScrollingMarquee1.MarqueeText += " " & readXML.Value
End If
End While
End Sub
___________________________________________________________________________
@obi1kenobi
Quote:
Originally Posted by obi1kenobi
Great control! I think you should post it in the CodeBank!
Thanks! I probably will put it in the code bank.