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


C# RichTextBox.ScrollToCaret方法代码示例

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


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

示例1: 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

示例2: wyswietl

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

示例3: AppendText

 private void AppendText(RichTextBox box, string text)
 {
     Invoke(new MethodInvoker(() =>
     {
         box.AppendText(text + "\r\n");
         box.ScrollToCaret();
     }));
 }
开发者ID:rmc47,项目名称:K3Key,代码行数:8,代码来源:MainForm.cs

示例4: Append

 void Append(RichTextBox rtb, string message)
 {
     rtb.AppendText(message);
     if (rtb.TextLength > 2048) {
         rtb.Text = rtb.Text.Substring(rtb.TextLength - 2048);
     }
     rtb.SelectionStart = rtb.TextLength;
     rtb.ScrollToCaret();
 }
开发者ID:nyoung3,项目名称:BukkitService,代码行数:9,代码来源:ConsoleForm.cs

示例5: UyariGoster

        public void UyariGoster(string msj, RichTextBox txtMesajlar)
        {
            if (txtMesajlar.Text != "")
            {
                txtMesajlar.AppendText("\r\n");
            }

            Yazdir("Bilgi: " + msj, adtarihFontColor, adtarihFont, adtarihKertmeDegeri, "", txtMesajlar);
            txtMesajlar.ScrollToCaret();
        }
开发者ID:ugurcicekfidan,项目名称:VisualStudioWorks,代码行数:10,代码来源:MesajFormat.cs

示例6: AppendText

 public static void AppendText(RichTextBox box, string text, Color color)
 {
     box.SelectionStart = box.TextLength;
     box.SelectionLength = 0;
     box.SelectionColor = color;
     box.AppendText(text);
     box.SelectionColor = box.ForeColor;
     box.SelectionStart = box.TextLength;
     box.ScrollToCaret();
     box.Refresh();
 }
开发者ID:idiot000,项目名称:C-Sharp-Practice,代码行数:11,代码来源:Framer.cs

示例7: appendMsg

 public void appendMsg(RichTextBox t, string text)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action<RichTextBox, string>(appendMsg), new object[] { t, text });
     }
     else
     {
         t.AppendText(text);
         t.ScrollToCaret();
     }
 }
开发者ID:fajoy,项目名称:RTSPExample,代码行数:12,代码来源:Form1.cs

示例8: Log

 /// <summary>
 /// Logger to be able to see the events and operations in the server
 /// </summary>
 /// <param name="control"></param>
 /// <param name="message"></param>
 public static void Log(RichTextBox control, string message)
 {
     string formatted = string.Format("\r\n[{0}] {1}", DateTime.Now.ToString("MM-dd-yy hh:mm:ss"), message);
     /// Invoke the message to the controll
     /// http://msdn.microsoft.com/en-us/library/system.windows.forms.methodinvoker.aspx
     if (!control.IsDisposed)
     {
         if (!control.InvokeRequired)
         {
             control.AppendText(formatted);
             control.ScrollToCaret();
         }
         else
         {
             control.Invoke(((MethodInvoker)delegate
             {
                 control.AppendText(formatted);
                 control.ScrollToCaret();
             }));
         }
     }
 }
开发者ID:AaronTrazona,项目名称:BusTerminalApplication,代码行数:27,代码来源:ServerUtility.cs

示例9: AppendText

 private void AppendText(RichTextBox ctrl, string text)
 {
     if (ctrl.InvokeRequired)
     {
         AppendText_Callback call = new AppendText_Callback(AppendText);
         ctrl.Invoke(call, ctrl, text);
     }
     else
     {
         ctrl.AppendText(text);
         ctrl.ScrollToCaret();
     }
 }
开发者ID:HaKDMoDz,项目名称:geff,代码行数:13,代码来源:FrmParallelAStar.cs

示例10: AddMessage

 /// <summary>
 /// Пишет сообщение в RichBox и в файл лога.
 /// </summary>
 /// <param name="logBox"></param>
 /// <param name="message"></param>
 /// <param name="logType">0-info;1-ошибка</param>
 static void AddMessage(RichTextBox logBox, string message, int logType)
 {
     logBox.AppendText($"\n{message}\n");
     logBox.Refresh();
     logBox.ScrollToCaret();
     if (logType == 0)
     {
         log.Info(message);
     }
     else
     {
         log.Error(message);
     }
 }
开发者ID:iluxa1810,项目名称:DBPather,代码行数:20,代码来源:Form1.cs

示例11: MesajGoster

        public void MesajGoster(string msj, string ad, RichTextBox txtMesajlar)
        {
            StringBuilder sbAdTarih = new StringBuilder();

            if (txtMesajlar.Text != "") // Ýlk mesaj geldiðinde bir alt satýra(caret için) geçilmesin, diðer mesajlarda geçilsin...
            {
                txtMesajlar.AppendText("\r\n");
            }

            sbAdTarih.Append(ad).Append(" [").Append(DateTime.Now.ToShortTimeString()).Append("] : ");
            Yazdir(sbAdTarih.ToString(), adtarihFontColor, adtarihFont, adtarihKertmeDegeri, "\r\n", txtMesajlar);
            Yazdir(msj, yazilarFontColor, yazilarFont, yazilarKertmeDegeri, "",txtMesajlar);

            txtMesajlar.ScrollToCaret(); // Scroolbar aþaðý insin. caret = cursor
        }
开发者ID:ugurcicekfidan,项目名称:VisualStudioWorks,代码行数:15,代码来源:MesajFormat.cs

示例12: SetText

 private void SetText(RichTextBox tb, string text)
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (tb.InvokeRequired)
     {
         SetTextCallback d = new SetTextCallback(SetText);
         this.BeginInvoke(d, new object[] { tb, text });
     }
     else
     {
         tb.AppendText(text);
         tb.ScrollToCaret();
     }
 }
开发者ID:AlexandrSurkov,项目名称:PKStudio,代码行数:16,代码来源:KeilGeneratorTool.cs

示例13: AddMessageToControlInvoke

 private void AddMessageToControlInvoke(RichTextBox sender, String message)
 {
     if (sender.InvokeRequired)
     {
         sender.Invoke(addMessage, message);
     }
     else
     {
         if (!String.IsNullOrEmpty(message))
         {
             sender.Text += String.Format("[{0}]{1}\r\n", DateTime.Now.ToString("yyMMdd HH:mm:ss"), message);
             sender.SelectionStart = richTextBoxReceiver.TextLength;
             sender.ScrollToCaret();
         }
     }
 }
开发者ID:raindyi,项目名称:LearningProject,代码行数:16,代码来源:ServerForm.cs

示例14: AppendInternal

        public static void AppendInternal(RichTextBox richTextBox, Color colorFore, Color colorBack, FontStyle newStyle, string text)
        {
            if(richTextBox != null && !string.IsNullOrEmpty(text) && !richTextBox.IsDisposed)
            {
                if(richTextBox.InvokeRequired)
                {
                    richTextBox.BeginInvoke(new MethodInvoker(delegate() { AppendInternal(richTextBox, colorFore, colorBack, newStyle, text); }));
                }
                else
                {
                    lock(richTextBox)
                    {
                        richTextBox.SuspendLayout();

                        //Truncate as necessary
                        if(richTextBox.Text.Length + text.Length > _maxConsoleTextLength)
                        {
                            int truncateLength = _maxConsoleTextLength / 4;
                            int endmarker = richTextBox.Text.IndexOf('\n', truncateLength) + 1;
                            if(endmarker < truncateLength)
                                endmarker = truncateLength;
                            richTextBox.Select(0, endmarker);
                            richTextBox.Cut();
                        }

                        int originalTextEnd = richTextBox.Text.Length;
                        richTextBox.AppendText(text);
                        richTextBox.Select(originalTextEnd, text.Length);
                        if(colorFore != Color.Empty)
                            richTextBox.SelectionColor = colorFore;
                        if(colorBack != Color.Empty)
                            richTextBox.SelectionBackColor = colorBack;

                        //if(newStyle != richTextBox.Font.Style)
                        richTextBox.SelectionFont = new Font(richTextBox.Font, newStyle);

                        richTextBox.SelectionLength = 0;
                        richTextBox.ScrollToCaret();
                        richTextBox.ResumeLayout();
                        richTextBox.Update();
                    }
                }
            }
        }
开发者ID:jeoffman,项目名称:JkhSettings,代码行数:44,代码来源:RichTextBoxHelper.cs

示例15: exec_Sql

        public DataTable exec_Sql(string sql, NpgsqlConnection conn,RichTextBox t)
        {
            DataTable dt = new DataTable();
            try
            {

                NpgsqlCommand cmd = new NpgsqlCommand(sql, conn);
                NpgsqlDataReader r;

                r = cmd.ExecuteReader();
                if (r.HasRows)
                {
                    dt.Load(r);
                    r.Close();
                }
                r.Close();

                int length = t.TextLength;
                string msg = "Succesfull Query!";
                t.AppendText(DateTime.Now + " "+msg + "\n");

                t.SelectionStart = length;
                int flength = msg.Length + DateTime.Now.ToString().Length + 1;
                t.SelectionLength = flength;
                t.SelectionColor = Color.Green;
                t.ScrollToCaret();

            }
            catch (Exception ex)
            {
                int length = t.TextLength;

               t.AppendText(DateTime.Now + " " + ex.Message + "\n");

                t.SelectionStart = length;
                int flength = ex.Message.Length + DateTime.Now.ToString().Length + 1;
                t.SelectionLength = flength;
                t.SelectionColor = Color.Red;
                t.ScrollToCaret();

            }

            return dt;
        }
开发者ID:carlosv14,项目名称:Postgres-Manager,代码行数:44,代码来源:Postgres_Connection.cs


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