【问题标题】:Making a scrolling Text in the title bar in c# in a visual studio form在 Visual Studio 表单中的 c# 标题栏中制作滚动文本
【发布时间】:2022-01-13 20:47:06
【问题描述】:

我需要在 Visual Studio 2019 windows.net 框架表单的标题栏中创建一个滚动文本(选取框)。我尝试了许多不同的想法,但似乎无法让它发挥作用。我知道有人提到他们用两行代码和一个变量和长度属性来做到这一点,但我想不通。有什么想法吗?

【问题讨论】:

  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: c# forms visual-studio


【解决方案1】:

这是一种方法:

using System;
using System.Windows.Forms;

namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        private string _text;
        private Timer _textTimer;

        public Form1()
        {
            InitializeComponent();
            Closed += Form1_Closed;
        }

        private void _textTimer_Tick(object sender, EventArgs e)
        {
            if (Text == string.Empty)
            {
                Text = _text;
            }

            Text = Text.Substring(1);
        }

        private void Form1_Closed(object sender, EventArgs e)
        {
            _textTimer.Dispose();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            _text = Text;
            _textTimer = new Timer();
            _textTimer.Interval = 100;
            _textTimer.Tick += _textTimer_Tick;
            _textTimer.Start();
        }
    }
}

但与 WinAmp 不同的是,这发生在 表单和任务栏上。

一个好的行为是这样做only on the taskbar,因为在表单本身中看到它很快就会变得烦人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-03
    • 2018-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-23
    • 2019-05-07
    相关资源
    最近更新 更多