1. 程式人生 > >C#winform實現跑馬燈

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();
            }
        }
    }
}

相關推薦

C#winform實現馬燈

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text

C# Winform實現捕獲窗體最小化、最大化、關閉按鈕事件的方法

comm c# 基於 prot void 地址 tp服務器 plugin ant 本文實例講述了C# Winform實現捕獲窗體最小化、最大化、關閉按鈕事件的方法,主要是通過重寫WndProc來實現的。分享給大家供大家參考。具體方法如下: 主要功能代碼如下:const i

C# winform實現記住用戶登錄的登錄狀態

end lose 用戶名 clas for 用戶 final con ring namespace DMS { public class LoginInfo { public string AccountID {

C# WinForm實現Windows 7 Aero磨砂玻璃效果

代碼 ear bool 效果 lac err mis 桌面 onload 代碼 using System; using System.Collections.Generic; using System.ComponentModel; using System

c# winform 實現打印功能(未完)

ble preview raw using ntp review winform setup print 1.打印控件介紹(Document屬性設置為PrintDocument1;ShowDialog()方法顯示對話窗) PrintDialog控件(打印會話):用於選擇打印

C#Winform 實現資料的匯出為txt或者CSV或者excel

//filePath 為儲存到本地磁碟的位置 private void Export(string filePath) { using (FileStream fs=new FileStream(filePath,FileMode.Create,

小程式實現馬燈效果

跑馬燈效果比較常見,一般做電商類的小程式都會使用到; 跑馬燈效果的製作 製作方式很簡單,先方上程式碼,後面會對程式碼詳細講解 一、wxml介面的實現 <view class="example"> <view class="marquee_box">

使用依賴實現馬燈的橫向縱向實現

依賴依賴匯入依賴 //跑馬燈 implementation 'com.sunfusheng:marqueeview:1.3.3' xml檔案佈局 <!--mvAnimDuration一行文字動畫執行的時間--> <!--mvDirect

簡單實現馬燈效果

先看看效果 在build.gradle中匯入依賴 implementation ‘com.sunfusheng:marqueeview:1.3.3’ 佈局檔案 <?xml version="1.0" encoding="utf-8"?> <androi

Android 實現馬燈效果

這裡用到了HorizontalScrollView巢狀TextView,上xml佈局: <HorizontalScrollView android:id="@+id/horiSv" android:layout_width="match_parent"

微信小程式實現馬燈效果(完整程式碼)

在微信小程式 裡實現跑馬燈效果,類似滾動字幕或者滾動廣告之類的,使用簡單的CSS樣式控制,沒用到JS,效果如下圖: Wxml程式碼: <!--跑馬燈 Linyufan.com--> <view class="marquee_container" st

UGUI 實現馬燈效果

使用Mask,遮擋走出去的文字(掛載到背景上,程式碼和要滾動的文字作為其子物體的元件) using DG.Tweening; using System.Collections; using System.Collections.Generic; using U

C#winform實現滑鼠響應左鍵按下,並記下其座標

private void Form1_MouseClick(object sender, MouseEventArgs e) { this.label1.Text = "相對座標:" +this.PointToClient(Mous

自定義MarqueeTextView字型沒有超過螢幕大小也能實現馬燈效果.

第一篇文章小白一名直接上程式碼吧 第一步:這個是自定義跑馬燈的類 public class MarqueeTextView extends android.support.v7.widget.AppCompatTextView { /** * 是否停止滾動 */ private boolea

Android TextView 實現馬燈效果

自定義一個TextView控制元件 public class MarqueeTextView extends AppCompatTextView { public MarqueeTextView(Context context) { s

Android Studio中TextView實現馬燈效果

自建一個MarqueeText 類 繼承自AppCompatTextView並重載父類的三個構造方法,新增一個isFocused方法 public class MarqueeText extends AppCompatTextView { public Marque

h5 實現馬燈效果

最近有個專案需要跑馬燈的效果,然而本人比較懶,不想寫js; 於是搜尋了一下,知道h5中有這麼一個標籤可以實現跑馬燈效果! 這裡給大家分享一下: marquee標籤不是HTML3.2的一部分,並且只支援MSIE3以後核心,所以如果你使用非IE核心瀏覽器(

C#Winform實現無邊框窗體滑鼠拖動

在有時候我們為了實現軟體的美觀,我們需要把窗體的邊框隱藏,但是問題也會隨之而來,在屬性中設定了FormBorderStyle應該為None,邊框便可以隱藏,但是我們在使用軟體時卻無法拖動窗體,

Android中TextView不獲取焦點可以實現馬燈的效果

第一種: Animation ani = new TranslateAnimation(310f, -400f, 0.0f, 0.0f);   ani.setDuration(10000);   ani.setRepeatCount(500);   ani.se

使用TextView實現馬燈Marquee

1、定義textView標籤的4個屬性: android:singleLine=”true”//使其只能單行 android:ellipsize=”marquee”//去掉省略號 android:focusable = “true”//使其迴圈 andr