Easy to Use Marquee Control for Windows Form with Full Designer Support






4.66/5 (34 votes)
Marque control implementation using .NET 2.0
- Download demo - 91.57 KB
- Download lib - 20.2 KB
- Download source - 113.99 KB
- Download help - 229.24 KB

Introduction
This is a simple to use Marquee implementation for Windows Forms using .NET 2.0. This control allows you to customize itself easily and within seconds.
Background
I was looking for a Marquee control for Window Forms. I found a couple but they were very restricted in features and moreover they were very restricted in events.
I decided to write a control which will fulfill all of my needs. Further it should be generic enough to be used by others too.
Features
Marquee control has the following features:
- Easy to use interface
- Design time support for control and marquee element
- ToolTip Support
- Support of various events
- Support for multicolor marquee
- Support for left and right image in marquee element
- Support for Font in marquee
- Hover stop feature
- Marquee element click and double click support
- Notifies when lap is completed
Using Code
You can use this control in two ways.
Via Designer
Use dragdrop feature of Visual Studio. I will recommend to use the compiled assembly for references. Otherwise if recompiling of assembly is done, you will need to restart Visual Studio.

Use designer of SuperMarquee to modify the control.

Use Properties of control to fine tune the rest of the properties:

Use Element collection editor to modify TextElement
collection:

Use element designer to set element properties.

Via Code
MarqueControl.Controls.SuperMarquee superMarquee1 =
new MarqueControl.Controls.SuperMarquee();
Use the following code to add element to the control:
TextElement element = new TextElement("Element text");
element.LeftImageIndex = 0;
element.RightImageIndex = 1;
element.IsLink = true;
element.ForeColor = Color.Red;
element.Tag = "Tag for element";
element.Font = new Font("Microsoft Sans Serif", 8.25F);
element.ToolTipText = "Tool tip for element";
superMarquee1.Elements.Add(element);
Alternatively you can use the following code snippet to add a new range of elements:
MarqueControl.Entity.TextElement textElement1 =
new MarqueControl.Entity.TextElement("TextElement 1");
MarqueControl.Entity.TextElement textElement2 =
new MarqueControl.Entity.TextElement("TextElement 2");
MarqueControl.Entity.TextElement textElement3 =
new MarqueControl.Entity.TextElement("TextElement 3");
superMarquee1.Elements.AddRange(new MarqueControl.Entity.TextElement[]
{
textElement1,
textElement2,
textElement3
}
);
Events Description
ItemClicked
This event is fired when user presses mouse button on the element text area.
private void superMarquee1_ItemClicked(object sender, ItemClickEventArgs e)
{
MessageBox.Show("Item clicked :" + e.Index);
}
Note
- This event is fired when any button is pressed.
- This event is fired only if clicked in text area of the element.
ItemDoubleClicked
This event is fired when user double clicks on the element text area. This has similar features as of ItemClicked
.
private void superMarquee1_ItemDoubleClicked(object sender, ItemClickEventArgs e)
{
MessageBox.Show("Item double clicked :" + e.Index);
}
LapCompleted
This event is fired when a lap is completed. Applicable only if AutoRewind
is set to true
. This event can be used in the following manner:
private void superMarquee1_LapCompleted(object sender, System.EventArgs e)
{
MessageBox.Show("Lap completed.");
}
BeforeToolTip
This event is fired before tooltip is popped. It supports cancellation of the tooltip being displayed. Apart from cancel feature, it supports the following:
ToolTipText
- Used to set ToolTip textLocation
- Used to set location of the tooltipCancel
- Used to cancel popup of tooltip
HitTest and HitTestInfo Object
HitTest()
function can be used for get information on position of a point relative to the control.
HitTestInfo
object contains the following properties:
Index
- Index of theTextElement
if point is above element otherwise it is-1
Point
- Point whereHitTest
was performedArea
-HitTestArea
at which point is located
HitTestArea
enumeration contains the following members:
Item
-Point
is aboveItem
. This does not includeLeftImage
orRightImage
LeftImage
-Point
is aboveLeftImage
of the elementRightImage
-Point
was hit onRightImage
of the elementStrip
-Point
was hit onStrip
Control
-Point
is inside the control, but not aboveItem
,LeftImage
,RightImage
orStrip
None
-Point
is outside the bounds of control
HitTestInfo test = superMarquee1.HitTest(PointToClient(MousePosition));
switch(test.Area)
{
case HitTestArea.Item:
break;
case HitTestArea.LeftImage:
break;
case HitTestArea.RightImage:
break;
case HitTestArea.Strip:
break;
case HitTestArea.Control:
break;
case HitTestArea.None:
break;
}
Alternatively you can create a new instance of the HitTestInfo
class in the following manner:
HitTestInfo test = new HitTestInfo(superMarquee1, PointToClient(MousePosition));
switch(test.Area)
{
case HitTestArea.Item:
break;
case HitTestArea.LeftImage:
break;
case HitTestArea.RightImage:
break;
case HitTestArea.Strip:
break;
case HitTestArea.Control:
break;
case HitTestArea.None:
break;
}
ToolTip and ToolTipData Object
To use tooltip property AutoToolTip
must be set to true
. Predefined tooltip can be used or dynamic tooltip can also be used using event BeforeToolTip
.
The following code snippet illustrates how to add dynamic tooltip to the element.
private void superMarquee1_BeforeToolTip
(object sender, GenericCancelEventArgs <ToolTipData> tArgs)
{
tArgs.Value.ToolTipText = "New dynamic text based on condition.";
}
The code below will illustrate how to change the position of the tooltip being displayed.
private void superMarquee1_BeforeToolTip
(object sender, GenericCancelEventArgs<ToolTipData> tArgs)
{
tArgs.Value.Location =
new Point(tArgs.Value.Location.X + 10, tArgs.Value.Location.Y + 20);
}
This is how your tooltip display can be cancelled.
private void superMarquee1_BeforeToolTip(object sender, GenericCancelEventArgs tArgs)
{
tArgs.Cancel = true;
}
Points of Interest
SuperMarquee
Properties
HoverStop
- Gets or sets that marquee will be running or not if mouse hover is thereAutoRewind
- Gets or sets on completion of one round of marquee it will start again or notElements
- Gets list of theTextElement
associated with the control.Running
- Gets or sets whether marquee is running or notAutoToolTip
- Gets or sets whether tool tip will be shown automaticallyImageList
- Gets or sets theImageList
associated with the componentStripColor
- Gets or sets theColor
of the stripe. EnableShowStrip
for displaying the strip.ShowStrip
- Gets or sets thatstrip
will be shown or not.MarqueeSpeed
- Gets or sets theSpeed
of the marquee. Maximum speed is999
and minimum speed is1
.
Events
ItemClicked
- Fired whenItem
is clickedItemDoubleClicked
- Fired whenItem
is double clickedLapCompleted
- Fired when lap is completedBeforeToolTip
- Fired when ToolTip is about to display
Methods
HitTest()
- Performs theHitTest
Reset()
- Reset the controlResetMorquee()
- Reset the marquee of controlStartMarquee()
- Starts marqueeStopMarquee()
- Stops marquee
TextElement
Properties
Text
- Text displayed in this elementForeColor
- Text color of the elementIsLink
- Indicates whether the element will be displayed as a link or notFont
- Font of this elementTag
- User data associated with the elementLeftImageIndex
- Left image index of the image to be displayedRightImageIndex
- Right image index of the image to be displayedToolTipText
- Text displayed in this element
Methods
Reset()
- Reset the element
Known Issues
- At high speed, flickering is there
- Element jumping is sometimes not proper
History
- 24 March 2008: Initial draft of the control