0

I'm trying to make a marquee (or ticker) control for text that wraps when it hits the end of the control. I've seen many examples and I've been able to make one with a label, but I can't figure out the best way to make it wrap the text to the other side. I saw one example, but it continually manipulates a string and I just don't like the idea of wasting memory like that.

Synaps3
  • 1,597
  • 2
  • 15
  • 23

1 Answers1

0

Create a CustomUserControl inherited by WebBrowser control then assign a <HTML> content to that browser control when the Text property is changed.

public partial class UserControl1 : WebBrowser
{
    private string _text = string.Empty;
    [Browsable(true)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    public override String Text
    {
        get
        {
            return _text;
        }
        set
        {
            _text = value;
            this.DocumentText = getContent(_text);
        }

    }
    private string getContent(string _value)
    {
        return string.Format("<HTML><marquee>{0}</marquee></HTML>", _value);
    }
    public UserControl1()
    {
        InitializeComponent();
    }
}
Shell
  • 6,818
  • 11
  • 39
  • 70