13 Replies - 27822 Views - Last Post: 09 June 2010 - 06:25 AM Rate Topic: -----

#1 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 40
  • View blog
  • Posts: 1,162
  • Joined: 23-June 08

Scrolling Text

Posted 08 October 2008 - 06:49 AM

I am trying to scroll text. I know how to scroll it in HTML Code: <marquee>Scroll Text</marquee>, but was wondering if C# has a special function like the marquee function.
Is This A Good Question/Topic? 0
  • +

Replies To: Scrolling Text

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Scrolling Text

Posted 08 October 2008 - 07:15 AM

No there is not, at least that I am aware of. You are going to have to implement this functionality yourself.
Was This Post Helpful? 0
  • +
  • -

#3 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 40
  • View blog
  • Posts: 1,162
  • Joined: 23-June 08

Re: Scrolling Text

Posted 08 October 2008 - 07:26 AM

Ok Thanks
Was This Post Helpful? 0
  • +
  • -

#4 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: Scrolling Text

Posted 08 October 2008 - 08:55 AM

To scroll a label, all you have to do is change the location:
		public void ScrollingLabel(Label l) {
			for (int i = l.Location.X; i >= 0; i--) {
				l.Location = new Point(l.Location.X-1, l.Location.Y);
				System.Threading.Thread.Sleep(50);
			}
		}


The problem is, it'll take over all control (It's in a loop, nothing else can be processed)

One way to do it would be to put it in a thread, using Invoke like I showed you before.

:)
Was This Post Helpful? 1
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Scrolling Text

Posted 08 October 2008 - 10:05 AM

I had to do this for a customer... this will scroll text inside of a textbox by removing the first character and placing it at the end of the string.

delegate for scrolling and class level variable
public delegate void ScrollTextboxCallback(string t);
string marqueeText = "This is only a test.";



Tread to start the marquee
Thread thread = new Thread(new ThreadStart(ScrollTextbox));
thread.Start();



ScrollTextbox method
private void ScrollTextBox()
{
      string tempChar = string.Empty;
      string tempText = string.Empty;
      tempText = marqueeText + "      ";  // adds spaces at the end of the text so there is a clear ending to the text
    
      while (true)
      {
             tempChar = tempText.SubString(0,1);
             tempText = tempText.Remove(0,1) + tempChar;
             textBox1.Invoke(new ScrollTextboxCallback(this.UpdateTextBox), new object[] { tempText });
             Thread.Sleep(100);  //lowering this value with make the marquee scroll faster
      }
}



UpdateTextBox method
private void UpdateTextBox(string m_text)
{
     textBox1.Text = m_text;
}


This post has been edited by eclipsed4utoo: 08 October 2008 - 10:07 AM

Was This Post Helpful? 1
  • +
  • -

#9 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 40
  • View blog
  • Posts: 1,162
  • Joined: 23-June 08

Re: Scrolling Text

Posted 08 October 2008 - 03:08 PM

Thanks Guys!
Was This Post Helpful? 1

#10 Adkins  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 66
  • View blog
  • Posts: 560
  • Joined: 27-October 09

Re: Scrolling Text

Posted 07 June 2010 - 12:16 AM

Sorry to revive an old post, but I was wondering what the best approach would be to scroll a paragraph up the screen. Not like a marquee, but more like the opening from Star Wars. Thoughts are appreciated, and so is a kick in the right direction.
Was This Post Helpful? 0
  • +
  • -

#11 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Scrolling Text

Posted 07 June 2010 - 09:05 AM

View PostAdkins, on 07 June 2010 - 02:16 AM, said:

Sorry to revive an old post, but I was wondering what the best approach would be to scroll a paragraph up the screen. Not like a marquee, but more like the opening from Star Wars. Thoughts are appreciated, and so is a kick in the right direction.


put a bunch of carriage returns at the beginning of the text...then remove one by one?
Was This Post Helpful? 0
  • +
  • -

#12 Adkins  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 66
  • View blog
  • Posts: 560
  • Joined: 27-October 09

Re: Scrolling Text

Posted 07 June 2010 - 11:50 PM

I was hoping for something a little more graceful and flowing. If I take that approach I am assuming the text would be shaky and bouncing
Was This Post Helpful? 0
  • +
  • -

#13 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Scrolling Text

Posted 08 June 2010 - 05:46 AM

are you doing this in WinForms? In WPF or Silverlight, you could definitely use an animation to do it.
Was This Post Helpful? 0
  • +
  • -

#14 Adkins  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 66
  • View blog
  • Posts: 560
  • Joined: 27-October 09

Re: Scrolling Text

Posted 08 June 2010 - 11:41 PM

it is WinForms. I haven't actually looked into Silverlight or WPF, but I think it might be time to cave in and check it out. I specialize soley in desktop applications and from the blurbs that I have read I got the impression that those two were intended more for the web dev crowd.
Was This Post Helpful? 0
  • +
  • -

#15 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Scrolling Text

Posted 09 June 2010 - 05:37 AM

View PostAdkins, on 09 June 2010 - 01:41 AM, said:

it is WinForms. I haven't actually looked into Silverlight or WPF, but I think it might be time to cave in and check it out. I specialize soley in desktop applications and from the blurbs that I have read I got the impression that those two were intended more for the web dev crowd.


WPF is for Windows development. Silverlight is for web. I would suggest at least looking into WPF.
Was This Post Helpful? 1
  • +
  • -

#16 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Scrolling Text

Posted 09 June 2010 - 06:05 AM

Wow! Talk about Necro! :D

The way I would do it is create a thread, and in that thread modify the .Location property of the control to have it give the illusion of scrolling vertically. But really, look into WPF; it's sexy.
Was This Post Helpful? 1
  • +
  • -

#17 Adkins  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 66
  • View blog
  • Posts: 560
  • Joined: 27-October 09

Re: Scrolling Text

Posted 09 June 2010 - 06:25 AM

As soon as I am done working I am going to check out WPF. Pardon my ignorance :P Thanks for the help though!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1