当前位置: 首页>>代码示例>>C#>>正文


C# RichTextBox.AppendText方法代码示例

本文整理汇总了C#中System.Windows.Forms.RichTextBox.AppendText方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.AppendText方法的具体用法?C# RichTextBox.AppendText怎么用?C# RichTextBox.AppendText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.RichTextBox的用法示例。


在下文中一共展示了RichTextBox.AppendText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AppendMsg

 /// <summary>
 /// 在富文本上打印消息
 /// </summary>
 /// <param name="richTextBox1">所在打印的富文本</param>
 /// <param name="color">打印字体颜色</param>
 /// <param name="text">要打印的文本</param>
 /// <param name="AutoTime">是否在每条打印结果前追加时间</param>
 public void AppendMsg(RichTextBox richTextBox1, Color color, string text,bool AutoTime)
 {
     richTextBox1.BeginInvoke(new ThreadStart(() =>
      {
          lock (richTextBox1)
          {
              //为控件输入焦点
              richTextBox1.Focus();
              //检查文本框过长
              if (richTextBox1.TextLength > 100000 )
              {
                  richTextBox1.Clear();
              }
              //得到有格式的文本
              using (var temp = new RichTextBox())
              {
                  temp.SelectionColor = color;
                  if (AutoTime)
                      temp.AppendText(DateTime.Now.ToString("yyyyMMdd HH:mm:ss"));
                  temp.AppendText(text);
                  //追加文本
                  richTextBox1.Select(richTextBox1.Rtf.Length, 0);
                  richTextBox1.SelectedRtf = temp.Rtf;
              }
              //设定光标所在位置
              //richTextBox1.SelectionStart = richTextBox1.TextLength;
              //滚动到当前光标处
              //richTextBox1.ScrollToCaret();
          }
      }));
 }
开发者ID:raintion,项目名称:EmuchSign,代码行数:38,代码来源:HandleMsg.cs

示例2: AppendMessage

        /// <summary>
        /// Writes a message to the specified RichTextBox.
        /// </summary>
        /// <param name="textBox"></param>
        /// <param name="message">The <see cref="string">message</see> to be written.</param>
        /// <param name="col"></param>
        private static void AppendMessage(RichTextBox textBox, string message, Color col)
        {
            try
            {
                if (!textBox.IsDisposed)
                {
                    if (textBox.InvokeRequired)
                    {
                        textBox.Invoke(new Action<RichTextBox, string, Color>(AppendMessage), textBox, message, col);
                        return;
                    }

                    Color oldColor = textBox.SelectionColor;
                    textBox.SelectionColor = col;
                    textBox.AppendText(message);
                    textBox.SelectionColor = oldColor;
                    textBox.AppendText(Environment.NewLine);
                    textBox.ScrollToCaret();
                }
            }
            catch (Exception ex)
            {
                Logging.WriteException(ex);
            }
        }
开发者ID:RaptorFactor,项目名称:devmaximus,代码行数:31,代码来源:Log.cs

示例3: getAuthorAndTitles_GroupByAuthor

        public static RichTextBox getAuthorAndTitles_GroupByAuthor()
        {
            BooksDataContext dc = new BooksDataContext();

            var authTitle = (from author in dc.GetTable<Author>()
                             orderby author.LastName, author.FirstName
                             let name = author.FirstName + " " + author.LastName
                             let titles =
                                 from book in author.AuthorISBNs
                                 orderby book.Title.BookTitle
                                 select book.Title.BookTitle
                             select new { Name = name, Titles = titles });

            RichTextBox temp = new RichTextBox();

            temp.AppendText("Titles Grouped by Author:\n");

            // display titles written by each author, grouped by author
            foreach ( var author in authTitle )
            {
                // display author's name
                temp.AppendText("\t" + author.Name + ":\n");

                // display titles written by that author
                foreach ( var title in author.Titles )
                {
                    temp.AppendText("\t\t" + title+"\n");
                } // end inner foreach
            } // end outer foreach

            return temp;
        }
开发者ID:berickson926,项目名称:cecs475proejct5,代码行数:32,代码来源:Accessor.cs

示例4: AddLine

 private void AddLine(RichTextBox RTB, string line)
 {
     if (RTB.InvokeRequired)
         RTB.Invoke(new Action(() => RTB.AppendText(line + Environment.NewLine)));
     else
         RTB.AppendText(line + Environment.NewLine);
 }
开发者ID:DatKami,项目名称:FEAT,代码行数:7,代码来源:Form1.cs

示例5: AddText

 private void AddText(RichTextBox RTB, string msg)
 {
     if (RTB.InvokeRequired)
         RTB.Invoke(new Action(() => RTB.AppendText(msg)));
     else
         RTB.AppendText(msg);
 }
开发者ID:DatKami,项目名称:FEAT,代码行数:7,代码来源:Form1.cs

示例6: SetText

        public static void SetText(string text, RichTextBox tb)
        {
            if (tb.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText);
                tb.Invoke(d, new object[] { text, tb });

            }
            else
            {
                tb.AppendText(text);
                tb.AppendText("\r\n");
            }
        }
开发者ID:Kentarre,项目名称:XmppClient,代码行数:14,代码来源:chatMain.cs

示例7: DrawString

        public void DrawString()
        {
            RichTextBox richTextBox1 = new RichTextBox();
            richTextBox1.Font = new Font("Consolas", 18f, FontStyle.Bold);
            richTextBox1.BackColor = Color.AliceBlue;

            string sentence = "    Welcome To Secure Computer Program";
            richTextBox1.AppendText(sentence);
            richTextBox1.SelectionBackColor = Color.AliceBlue;
            richTextBox1.AppendText(" ");
            richTextBox1.Width += 500;
            richTextBox1.Height = 40;
            Controls.Add(richTextBox1);
        }
开发者ID:orib2222,项目名称:Cyber-Project,代码行数:14,代码来源:Form1.cs

示例8: BookingLockoutsForDate

        public void BookingLockoutsForDate(RichTextBox rtb, DateTime date)
        {
            rtb.Text = "";
            var unitOfWork = new UnitOfWork();
            var today = date.Date;
            var notes = unitOfWork.LockedOutDateRepository.Get(x => today < x.EndDate && today > x.StartDate,includeProperties:"LockOutTimes");

            notes = notes.OrderBy(x => x.DateCreated);
            if (notes.Count() > 0)
            {

                rtb.AppendBoldColoredLine("Locked:", System.Drawing.Color.Red);
                int i = 1;
                foreach (var note in notes)
                {
                    rtb.AppendBoldColoredLine(i + ". " + note.Name, System.Drawing.Color.Red);
                    string reason = note.Reason;

                    rtb.AppendLine(reason);
                    if (note.LockOutTimes.Count>0)
                    {
                        foreach(var v in note.LockOutTimes)
                        {
                            rtb.AppendText(v.StartTime.ToShortTimeString() + " - "+ v.EndTime.ToShortTimeString()+", " );

                        }
                    }
                }

            }
        }
开发者ID:tsunamisukoto,项目名称:Book-A-Majig2,代码行数:31,代码来源:DateService.cs

示例9: ViewDictionary

        public ViewDictionary()
        {
            Form viewDictionaryForm = new Form();
            viewDictionaryForm.StartPosition = FormStartPosition.CenterScreen;
            viewDictionaryForm.FormBorderStyle = FormBorderStyle.Fixed3D;
            viewDictionaryForm.Size = new Size(250, 185);
            viewDictionaryForm.MinimizeBox = false;
            viewDictionaryForm.MaximizeBox = false;
            viewDictionaryForm.Text = "Просмотр переводчика";
            #endregion

            RichTextBox richText = new RichTextBox();
            richText.Location = new Point(10, 10);
            richText.Size = new Size(215, 105);
            richText.ScrollBars = RichTextBoxScrollBars.ForcedVertical;
            richText.ReadOnly = true;
            for (int i = 0; i < ruText.Length; i++)
            {
                ruText[i] = File.ReadAllLines("ru.txt")[i];
                ukrText[i] = File.ReadAllLines("ukr.txt")[i];
                richText.AppendText(ruText[i] + " - " + ukrText[i] + "\n");
            }
            viewDictionaryForm.Controls.Add(richText);

            Button closeButton = new Button();
            closeButton.Location = new Point(150, 120);
            closeButton.Size = new Size(75, 25);
            closeButton.Text = "Закрыть";
            closeButton.DialogResult = DialogResult.OK;
            viewDictionaryForm.Controls.Add(closeButton);

            viewDictionaryForm.ShowDialog();
        }
开发者ID:AndreySaveliy,项目名称:ASKL,代码行数:33,代码来源:ViewDictionary.cs

示例10: OutputMessage

        /// <summary>
        /// Displays message to the user in a RichTextBox Control</summary>
        /// <param name="messageType">Message type, which modifies display of message</param>
        /// <param name="message">Text message to display</param>
        /// <param name="textBox">RichTextBox in which to display message</param>
        protected override void OutputMessage(OutputMessageType messageType, string message, RichTextBox textBox)
        {
            Color c;
            string messageTypeText;
            Font font;

            switch (messageType)
            {
                case OutputMessageType.Error:
                    c = Color.Red;
                    messageTypeText = "Danger!";
                    font = s_errorFont;
                    break;
                case OutputMessageType.Warning:
                    c = Color.Orange;
                    messageTypeText = "Careful.";
                    font = s_warningFont;
                    break;
                default:
                    c = Color.Beige;
                    messageTypeText = "<Yawn>";
                    font = Font;
                    break;
            }

            textBox.SelectionFont = font;
            textBox.SelectionColor = c;
            textBox.AppendText(messageTypeText + ": " + message);
        }
开发者ID:vincenthamm,项目名称:ATF,代码行数:34,代码来源:ShoutOutputService.cs

示例11: InitializeCompile

        public static void InitializeCompile(ISynchronizeInvoke _isi, RichTextBox _rtMain, Button _Compile)
        {
            CompileRich     = _rtMain;
            MainForm        = _isi;
            CompileButton   = _Compile;

            if (!Directory.Exists("Source"))
                Directory.CreateDirectory("Source");

            if (Settings.Default.CoreGit == "")
            {
                CompileRich.AppendText("Core will not compile\nReason: No Core git settings");
                CompileButton.Enabled = true;
                return;
            }

            if (!File.Exists("Source\\Core\\CMakeLists.txt"))
                CloneGit(GitTypes.Core);
            else
                PullGit(GitTypes.Core);

            if (!Directory.Exists("Database"))
                CloneGit(GitTypes.Database);
            else
                PullGit(GitTypes.Database);
        }
开发者ID:Singlem,项目名称:Portfolio,代码行数:26,代码来源:ComplieHandler.cs

示例12: wyswietl

 public void wyswietl(RichTextBox o, string tekst)
 {
     o.Focus();
     o.AppendText(tekst);
     o.ScrollToCaret();
     txtWysylane.Focus();
 }
开发者ID:morskee,项目名称:project-communicator,代码行数:7,代码来源:Serwer.cs

示例13: dodajWiadomosc

 public void dodajWiadomosc(RichTextBox rt, string w)
 {
     if (rt.InvokeRequired)
         rt.BeginInvoke(new Action<RichTextBox, string>(dodajWiadomosc), rt, w);
     else
         rt.AppendText(w + Environment.NewLine);
 }
开发者ID:JanekGreen,项目名称:simple-local-network-communicator,代码行数:7,代码来源:Form1.cs

示例14: ServerTab

        public ServerTab(ServerManager manager, PBUCONServer server)
        {
            this.manager = manager;
            this.server = server;

            // Create console box
            rtb = new RichTextBox();
            rtb.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
            rtb.BackColor = SystemColors.ControlLight;
            rtb.Font = new Font("Consolas", 9F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
            rtb.ForeColor = SystemColors.WindowText;
            rtb.Location = new Point(7, 7);
            rtb.ReadOnly = true;
            rtb.ScrollBars = RichTextBoxScrollBars.Vertical;
            rtb.Size = new Size(839, 354);
            rtb.TabIndex = 0;

            // Create send button
            sendButton = new Button();
            sendButton.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Right)));
            sendButton.Font = new Font("Segoe UI", 9F);
            sendButton.Location = new Point(771, 367);
            sendButton.Size = new Size(75, 23);
            sendButton.TabIndex = 2;
            sendButton.Text = "Send";
            sendButton.UseVisualStyleBackColor = true;
            sendButton.Click += new EventHandler(sendButton_Click);

            // Create command bar
            commandBox = new TextBox();
            commandBox.Anchor = ((AnchorStyles)(((AnchorStyles.Bottom | AnchorStyles.Left) | AnchorStyles.Right)));
            commandBox.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            commandBox.Location = new Point(7, 367);
            commandBox.Size = new Size(758, 23);
            commandBox.TabIndex = 1;
            commandBox.KeyPress += new KeyPressEventHandler(commandBox_KeyPress);

            // Create tab page that holds everything
            tab = new TabPage();
            tab.ImageIndex = 0;
            tab.Location = new Point(4, 23);
            tab.Name = server.Name;
            tab.Padding = new Padding(3);
            tab.Size = new Size(852, 396);
            tab.TabIndex = 0;
            tab.Text = server.Name;
            tab.UseVisualStyleBackColor = true;

            tab.Controls.Add(rtb);
            tab.Controls.Add(commandBox);
            tab.Controls.Add(sendButton);

            // Add events to the server
            server.NewMessage += NewMessage;
            server.ServerChallengeChanged += ChallengeChange;

            // Show the client challenge
            rtb.AppendText("Client challenge: " + server.ClientChallenge.ToString("X8") + "\n");
        }
开发者ID:McSimp,项目名称:OpenPBUCON,代码行数:59,代码来源:ServerTab.cs

示例15: ShowNotification

        void ShowNotification(string Header, string Body, int Duration)
        {
            List<string> Messages = new List<string>();

            RichTextBox Box = new RichTextBox();
            Box.Font = new Font("Tahoma", 8.25F);
            Box.SelectionColor = Color.FromArgb(204, 0, 0);
            Box.SelectionFont = new Font(Box.Font, FontStyle.Bold);
            Box.AppendText(Header);
            Box.SelectionColor = Box.ForeColor;
            Box.SelectionFont = Box.Font;
            Box.AppendText("\r\n" + Body);

            Messages.Add(Box.Rtf);

            ShowNotification(Messages, Duration);
        }
开发者ID:solymosi,项目名称:GmailNotifier,代码行数:17,代码来源:Notification.cs


注:本文中的System.Windows.Forms.RichTextBox.AppendText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。