zoukankan      html  css  js  c++  java
  • C#winform实现跑马灯

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Threading;
    namespace WindowsFormsApplication1
    {
        public partial class Form3 : Form
        {
            public Form3()
            {
                InitializeComponent();
            }
            delegate void show();
            Thread t=null;
            private void Form3_Load(object sender, EventArgs e)
            {
               t = new Thread(new ThreadStart(ShowLbl));
               t.Start();
            }
            public void ShowLbl()
            {
                while (true)
                {
                    if (panel1.InvokeRequired)
                    {
                        panel1.Invoke(new show(GetConfig));
                    }
                    Thread.Sleep(200);
                }
            }
            private void GetConfig()
            {
                try
                {
                    this.label2.Text = "中国传统文化博大精深,学习和掌握其中的各种思想精华,对树立正确的世界观、人生观、价值观很有益处。";
                    this.label1.Text = "中国传统文化博大精深,学习和掌握其中的各种思想精华,对树立正确的世界观、人生观、价值观很有益处。";
                    this.label1.Left = label1.Left - 10;
                    this.label2.Left = label1.Left + this.label1.Size.Width;
                    if (label1.Left + label1.Size.Width <= 0) 
                    {
                        label1.Left = label2.Left;
                        label2.Left = label1.Left + this.label1.Size.Width;
                    }
                }
                catch (Exception ex)
                {
                }
            }
            private void Form3_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (t != null) 
                {
                    t.Abort();
                }
            }
        }
    }
    

      

  • 相关阅读:
    与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误
    ExecuteNonQuery()>0
    Newtonsoft.Json 你必须知道的一些用法
    API Test WebApiTestClient工具安装及使用
    vb 无效的属性值,运行时错误380
    洛谷P4296 [AHOI2007] 密码箱——题解
    pip install mysql-python 安装错误解决方案,whl安装,exe 安装
    安装包模块出现的下载源问题解决:An HTTPS request has been made /Could not find a version that satisfies the requirement pyopenssl
    fast_admin 添加产品信息后台管理sql
    kafka 记录(转)
  • 原文地址:https://www.cnblogs.com/lgx5/p/9748434.html
Copyright © 2011-2022 走看看