最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#?WinForm?RichTextBox文本動(dòng)態(tài)滾動(dòng)顯示文本方式

 更新時(shí)間:2023年03月01日 08:35:15   作者:楚楚3107  
這篇文章主要介紹了C#?WinForm?RichTextBox文本動(dòng)態(tài)滾動(dòng)顯示文本方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

WinForm RichTextBox文本動(dòng)態(tài)滾動(dòng)顯示文本方

在RichTextBox動(dòng)態(tài)顯示一些文本信息時(shí),需要一些設(shè)置,顯示當(dāng)前要顯示的字符串。

一個(gè)RichTextBox,一個(gè)按鈕。

下圖為運(yùn)行時(shí)顯示過(guò)程中

Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace RichTextBoxScroll
{
    public partial class Form1 : Form
    {
        private delegate void delInfoList(string text);
        public Form1()
        {
            InitializeComponent();
        }
        
        private void SetrichTextBox(string value)
        {
 
            if (richTextBox1.InvokeRequired)//其它線程調(diào)用
            {
                delInfoList d = new delInfoList(SetrichTextBox);
                richTextBox1.Invoke(d, value);
            }
            else//本線程調(diào)用
            {
                if (richTextBox1.Lines.Length > 100)
                { 
                    richTextBox1.Clear();
                }
 
                richTextBox1.Focus(); //讓文本框獲取焦點(diǎn) 
                richTextBox1.Select(richTextBox1.TextLength, 0);//設(shè)置光標(biāo)的位置到文本尾
                richTextBox1.ScrollToCaret();//滾動(dòng)到控件光標(biāo)處 
                richTextBox1.AppendText(value);//添加內(nèi)容
            }
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 300; i++)
            {
                SetrichTextBox(DateTime.Now.ToString() + " 內(nèi)容滾動(dòng)打印中!!!\n");
            } 
        }
    }
}

Form1.Designer.cs

namespace RichTextBoxScroll
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
 
 
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
 
 
        #region Windows Form Designer generated code
 
 
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.panel1 = new System.Windows.Forms.Panel();
            this.button1 = new System.Windows.Forms.Button();
            this.richTextBox1 = new System.Windows.Forms.RichTextBox();
            this.panel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // panel1
            // 
            this.panel1.Controls.Add(this.button1);
            this.panel1.Controls.Add(this.richTextBox1);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel1.Location = new System.Drawing.Point(0, 0);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(706, 496);
            this.panel1.TabIndex = 0;
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(609, 85);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 1;
            this.button1.Text = "開(kāi)始測(cè)試";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // richTextBox1
            // 
            this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.richTextBox1.Font = new System.Drawing.Font("SimSun", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.richTextBox1.Location = new System.Drawing.Point(0, 0);
            this.richTextBox1.Name = "richTextBox1";
            this.richTextBox1.Size = new System.Drawing.Size(706, 496);
            this.richTextBox1.TabIndex = 0;
            this.richTextBox1.Text = "";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(706, 496);
            this.Controls.Add(this.panel1);
            this.Name = "Form1";
            this.Text = "滾動(dòng)打印測(cè)試";
            this.panel1.ResumeLayout(false);
            this.ResumeLayout(false);
 
 
        }
 
 
        #endregion
 
 
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.RichTextBox richTextBox1;
        private System.Windows.Forms.Button button1;
    }
}

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • C#中DateTime函數(shù)的詳細(xì)用法

    C#中DateTime函數(shù)的詳細(xì)用法

    這篇文章介紹了C#中DateTime函數(shù)的詳細(xì)用法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-06-06
  • 淺談C#多線程簡(jiǎn)單例子講解

    淺談C#多線程簡(jiǎn)單例子講解

    本篇文章主要介紹了C#多線程簡(jiǎn)單例子,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-12-12
  • C# IQueryable<T>揭開(kāi)表達(dá)式樹(shù)的神秘面紗

    C# IQueryable<T>揭開(kāi)表達(dá)式樹(shù)的神秘面紗

    這篇文章主要介紹了C# IQueryable<T>表達(dá)式樹(shù),對(duì)IQueryable<T>感興趣的同學(xué),必須要仔細(xì)看一下
    2021-04-04
  • unity 鼠標(biāo)移入彈出UI的操作

    unity 鼠標(biāo)移入彈出UI的操作

    這篇文章主要介紹了unity 鼠標(biāo)移入彈出UI的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-04-04
  • C#在復(fù)雜多線程環(huán)境下使用讀寫(xiě)鎖同步寫(xiě)入文件

    C#在復(fù)雜多線程環(huán)境下使用讀寫(xiě)鎖同步寫(xiě)入文件

    這篇文章介紹了C#在復(fù)雜多線程環(huán)境下使用讀寫(xiě)鎖同步寫(xiě)入文件的方法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-04-04
  • 如何用.NETCore操作RabbitMQ

    如何用.NETCore操作RabbitMQ

    這篇文章主要介紹了如何用.NETCore操作RabbitMQ,對(duì)中間件感興趣的同學(xué),可以參考下
    2021-05-05
  • C#中 城市線路圖的純算法以及附帶求極權(quán)值

    C#中 城市線路圖的純算法以及附帶求極權(quán)值

    本篇文章介紹了,在C#中城市線路圖的純算法以及附帶求極權(quán)值的方法,需要的朋友參考下
    2013-04-04
  • C#異步原理詳情

    C#異步原理詳情

    這篇文章主要介紹了C#異步原理,C#異步在C#5便發(fā)布了,是利用async關(guān)鍵字和await表達(dá)式表達(dá)的異步操作,下面文章下邊將詳細(xì)向大家介紹C#異步原理,感興趣得小伙伴可以參考一下
    2021-10-10
  • C#利用IDbDataAdapter/IDataReader實(shí)現(xiàn)通用數(shù)據(jù)集獲取

    C#利用IDbDataAdapter/IDataReader實(shí)現(xiàn)通用數(shù)據(jù)集獲取

    這篇文章主要為大家詳細(xì)介紹了C#利用IDbDataAdapter/IDataReader實(shí)現(xiàn)通用數(shù)據(jù)集獲取的相關(guān)知識(shí),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2024-11-11
  • C#如何將Excel轉(zhuǎn)換為PDF

    C#如何將Excel轉(zhuǎn)換為PDF

    這篇文章主要介紹了C#如何將Excel轉(zhuǎn)換為PDF問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-01-01

最新評(píng)論

女性| 滦南县| 略阳县| 桐庐县| 曲阜市| 哈巴河县| 阿合奇县| 修水县| 通化市| 墨玉县| 游戏| 天津市| 炎陵县| 葫芦岛市| 武陟县| 冀州市| 韶关市| 将乐县| 江安县| 太和县| 宁蒗| 吴忠市| 钦州市| 泽州县| 绿春县| 闸北区| 元谋县| 都兰县| 荔浦县| 习水县| 西吉县| 舒兰市| 二连浩特市| 湟源县| 宁国市| 蕉岭县| 广宁县| 阿拉善盟| 花垣县| 綦江县| 阳西县|