The HTML MARQUEE Element creates a scrolling text marquee, but there is not an equivalent provided by Microsoft for desktop applications. The following is a simple sample of a scrolling text marquee control for a Windows Forms application.
The control uses a Timer object. For each timer tick, the text to scroll is updated by moving the current first character to the last character position. This causes the affect of the text continually scrolling. The text is written directly to the control's window using TextRenderer.DrawText.
To use the control, simply add the UserControl to a form and then during execution, such as in the form's constructor, set the UserControl's Text property to the text to scroll. If you are unfamiliar with the use of UserControls, then simply add the ScrollingTextControl.cs file in the attached file to the project, then build the project to ensure that Visual Studio sees it as a UserControl, then drag the ScrollingTextControl from the Toolbox onto the form.
The following is the UserControl.
The following is the UserControl.
public partial class ScrollingTextControl : UserControl
{
Timer MarqueeTimer = new Timer();
String CurrentText = "Scrolling text";
String OurText;
public ScrollingTextControl()
{
InitializeComponent();
MarqueeTimer.Interval = 150;
MarqueeTimer.Enabled = true;
MarqueeTimer.Tick += new EventHandler(MarqueeUpdate);
}
public int Interval
{
get { return MarqueeTimer.Interval; }
set { MarqueeTimer.Interval = value; }
}
public override String Text
{
get { return OurText; }
set { OurText = value; CurrentText = OurText; }
}
private void ScrollingTextControl_Paint(object sender, PaintEventArgs e)
{
TextRenderer.DrawText(e.Graphics, CurrentText, Font, ClientRectangle,
SystemColors.ControlText);
}
void MarqueeUpdate(object sender, EventArgs e)
{
CurrentText = CurrentText.Substring(1) + CurrentText[0];
Invalidate();
}
}

Abdulrahman YusufPosted Nov 1, 2017, 9:15 AM
Thanks..very helpful.. Welcome
Former memberPosted Sep 11, 2016, 9:06 AM
Thanks
Hashim ShafiqPosted Aug 21, 2015, 10:17 PM
Nice
lucas juanPosted Jul 31, 2014, 11:27 PM
Hi How can I scroll it from bottom to top??
david wierPosted Jul 22, 2014, 11:26 AM
Two things - I'm setting forecolor and it does not work - always black. Also trying to use form resize so that autoscrollmargin is always 5,5 - - can't get that to work. Any ideas?
Sam HobbsPosted Apr 18, 2013, 10:00 AM
The font, color and length of the text can be changed the same way as for any control.
Abdur RahmanPosted Apr 18, 2013, 8:25 AM
I want to change font, color and length of the scrolling text. How could i do that..
neelesh masihPosted May 3, 2011, 2:54 AM
in Literal control i am using marquee when page opens its running marquee when i am selecting location (for change marquee text) its not working
Dorababu MekaeditedPosted Dec 10, 2010, 6:59 AMEdited Dec 10, 2010, 7:06 AM
How can i change the text color and also how can i set the time interval a little bit slow so that after completion of the given text it should come again
Anusha SrivastavaPosted Apr 6, 2010, 9:30 AM
Sir, In this code - void MarqueeUpdate(object sender, EventArgs e) { CurrentText = CurrentText.Substring(1) + CurrentText[0]; Invalidate(); } infinite loop is occurring and i have created this usercontrol but i am not able to import it on the form Sir i have written this code-- using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; namespace Marquee { public partial class ScrollingTextControl : UserControl { Timer MarqueeTimer = new Timer(); String CurrentText = "Hello"; String OurText; public ScrollingTextControl() { InitializeComponent(); MarqueeTimer.Interval = 150; MarqueeTimer.Enabled = true; MarqueeTimer.Tick += new EventHandler(MarqueeUpdate); } public int Interval { get { return MarqueeTimer.Interval; } set { MarqueeTimer.Interval = value; } } public override String Text { get { return OurText; } set { OurText = value; CurrentText = OurText; } } private void ScrollingTextControl_Paint(object sender, PaintEventArgs e) { TextRenderer.DrawText(e.Graphics, CurrentText, Font, ClientRectangle, SystemColors.ControlText); } void MarqueeUpdate(object sender, EventArgs e) { CurrentText = CurrentText.Substring(1) + CurrentText[0]; Invalidate(); } private void ScrollingTextControl_Load(object sender, EventArgs e) { } } } and using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Marquee { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { ScrollingTextControl scr = new ScrollingTextControl(); scr.Text = "Hello"; scr.ForeColor = Color.Black; this.Controls.Add(scr); } } } but some problem is occurring.