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


C# TextBox.ScrollToCaret方法代码示例

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


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

示例1: add_text

 public static void add_text(TextBox tb, object s)
 {
     if (tb.InvokeRequired)
         tb.Invoke(new Action<TextBox, object>(add_text), new object[] { tb, s });
     else
     {
         tb.AppendText(s.ToString());
         tb.ScrollToCaret();
     }
 }
开发者ID:HowieXue,项目名称:Hospital_projs,代码行数:10,代码来源:Helper.cs

示例2: PositionTextDisplay

 /// <summary>
 /// Position the carat at the end of the text to keep the last bit into view
 /// </summary>
 public static void PositionTextDisplay(TextBox box)
 {
     int length = box.Text.Length;
      if (Regex.IsMatch(box.Text, "(\r\n)$"))
      {
     length -= 2;
      }
      box.Select(length, 0);
      box.ScrollToCaret();
 }
开发者ID:MarkPaxton,项目名称:MCP-shared,代码行数:13,代码来源:TextHelper.cs

示例3: PrintText

 public void PrintText(TextBox textbox, string text)
 {
     if (textbox.InvokeRequired)
     {
         textbox.Invoke(new PrintTextCallback(PrintText), textbox, text);
     }
     else
     {
         textbox.Text += text;
         textbox.SelectionStart = textbox.Text.Length;
         textbox.ScrollToCaret();
     }
 }
开发者ID:colombmo,项目名称:itsi-gamification,代码行数:13,代码来源:TestPMForm1.cs

示例4: PrintText

 public void PrintText(string txt, TextBox printBox, Form owner)
 {
     if (printBox.InvokeRequired)
     {
         invokeTextBox d = new invokeTextBox(PrintText);
         owner.Invoke(d, txt, printBox, owner);
     }
     else
     {
         printBox.Text += txt;
         printBox.Select(printBox.Text.Length, 0);
         printBox.ScrollToCaret();
     }
 }
开发者ID:Radon222,项目名称:AsciiConverter,代码行数:14,代码来源:PrinterController.cs

示例5: DisplayData

 public void DisplayData(string msg, TextBox listBox1)
 {
     listBox1.Invoke(new EventHandler(delegate
     {
         //listBox1.Font = new Font("Tahoma", 10, FontStyle.Regular);
         //if (count > 720)
         //{
         //    listBox1.Text = string.Empty;
         //    count = 0;
         //}
         listBox1.Text += msg + "\r\n";
         listBox1.SelectionStart = listBox1.Text.Length;
         listBox1.ScrollToCaret();
     }));
 }
开发者ID:ThuTrangK57,项目名称:sigateWsan,代码行数:15,代码来源:ShowData.cs

示例6: appendLine

        public void appendLine(string text,TextBox textBox)
        {
            BeginInvoke((Action)(() =>
            {
                if (textBox.Text.Length > 32000)
                {
                    //新しいファイルに保存

                    textBox.Text = "";
                }

                textBox.AppendText(DateTime.Now.ToLongTimeString() + " " + text + Environment.NewLine);
                textBox.SelectionStart = textBox.Text.Length;
                textBox.ScrollToCaret();
            }));
        }
开发者ID:hirokinnp,项目名称:Scanner,代码行数:16,代码来源:Form_Log.cs

示例7: Atak

 public void Atak(Postac atakujacy, Postac cel, TextBox komunikaty)
 {
     if(CzyTrafiono(atakujacy,cel))
     {
         Wykonaj(atakujacy,cel);
         komunikaty.Text += string.Format("Atakujący {0} trafił {1}, użył umiejętności {2}\r\n",atakujacy.Nazwa,cel.Nazwa,Nazwa);
     }
     else
     {
         komunikaty.Text += string.Format("Atakujący {0} spudłował\r\n",atakujacy.Nazwa);
     }
     komunikaty.SelectionStart = komunikaty.Text.Length - 1;
     komunikaty.SelectionLength = 0;
     komunikaty.ScrollToCaret();
     ZaplacZaUzycie(atakujacy);
 }
开发者ID:Shattan,项目名称:RzezPoGrob,代码行数:16,代码来源:Umiejetnosc.cs

示例8: AddLogEntry

        public void AddLogEntry(string message,string thread)
        {
            if (!threadTabs.ContainsKey(thread))
            {

                TabPage tab = new TabPage();
                tab.Location = new System.Drawing.Point(4, 22);
                tab.Name = "tab" + thread.Trim().Replace(' ', '_');
                tab.Padding = new System.Windows.Forms.Padding(3);
                tab.Size = new System.Drawing.Size(859, 226);
                tab.Text = thread;
                tab.UseVisualStyleBackColor = true;
                threadTabs[thread] = tab;
                tabControl1.TabPages.Add(tab);

                TextBox txtLogBox = new TextBox();
                txtLogBox.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                txtLogBox.Location = new System.Drawing.Point(6, 6);
                txtLogBox.Multiline = true;
                txtLogBox.Name = "txtLogBox";
                txtLogBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
                txtLogBox.Size = new System.Drawing.Size(847, 214);
                txtLogBox.TabIndex = 1;
                tab.Controls.Add(txtLogBox);
                txtLogBox.Text += "[" + DateTime.Now.ToLongTimeString() + "] - " + message + Environment.NewLine;
                txtLogBox.SelectionStart = txtLogBox.Text.Length;
                txtLogBox.ScrollToCaret();
                txtLogBox.Refresh();
            }
            else
            {
                TabPage tab = threadTabs[thread];
                TextBox txtLogBox = (TextBox) tab.Controls[0];
                txtLogBox.Text += "[" + DateTime.Now.ToLongTimeString() + "] - " + message + Environment.NewLine;
                txtLogBox.SelectionStart = txtLogBox.Text.Length;
                txtLogBox.ScrollToCaret();
                txtLogBox.Refresh();
            }

            /*
            txtLogBox.Text += "[" + DateTime.Now.ToLongTimeString() + "] - " + message + Environment.NewLine;
            txtLogBox.SelectionStart = txtLogBox.Text.Length;
            txtLogBox.ScrollToCaret();
            txtLogBox.Refresh();
             */
        }
开发者ID:NoxHarmonium,项目名称:enform,代码行数:46,代码来源:LogBox.cs

示例9: LimitTextBox

 /*
  * limits input to integers and limits it to 0 to 100 values,
  * rough way, but it works, it would take quite some time to change it to different way
  * (like the ones on bottom that have two events for every textbox,
  *      both keypress and textchanged, maybe I'll change it eventually)
  *
  * `J` removed "LimitTextBoxRMax" and "LimitTextBoxRMin" variants that did the same thing
 */
 private void LimitTextBox(TextBox tbox)
 {
     if (tbox.Text.Length > 0)
     {
         try
         {
             int test = int.Parse(tbox.Text);
         }
         catch
         {
             tbox.Text = tbox.Text.Substring(0, tbox.Text.Length - 1);
             tbox.SelectionStart = tbox.Text.Length;
             tbox.ScrollToCaret();
         }
         if (tbox.Text.Length < 1) { tbox.Text = "0"; }   // `J` added this to prevent crash.
         else if (int.Parse(tbox.Text) > 100) tbox.Text = "100";
     }
 }
开发者ID:diamondialis,项目名称:crazys-wm-mod,代码行数:26,代码来源:tBoxEvnt.cs

示例10: AppendText

 public static void AppendText(TextBox textBox, string text)
 {
     // If the current thread is not the UI thread, InvokeRequired will be true
     if (textBox.InvokeRequired)
     {
         // If so, call Invoke, passing it a lambda expression which calls
         // UpdateText with the same label and text, but on the UI thread instead.
         textBox.Invoke((Action)(() => AppendText(textBox, text)));
         return;
     }
     // If we're running on the UI thread, we'll get here, and can safely update
     // the label's text.
     textBox.AppendText(text);
     textBox.ScrollToCaret();
 }
开发者ID:narugo,项目名称:SteamGrouper,代码行数:15,代码来源:Interface.cs

示例11: MakeEndOfTextVisibleAndFocus

		/// <summary>
		/// Make sure that the end of the text in the given text box is visible.
		/// An (undesired) side effect is to focus the box and put the selection at the end of it.
		/// I cannot find any portable way to achieve the desired scrolling without doing this.
		/// </summary>
		/// <param name="textBox"></param>
		private void MakeEndOfTextVisibleAndFocus(TextBox textBox)
		{
			if (textBox.Text.Length == 0)
				return;
			// It would seem logical that we would not want the -1, so we would be asking for the position of the
			// imaginary character at the very end. However, that just always returns (0,0).
			Point endPosition = textBox.GetPositionFromCharIndex(textBox.Text.Length - 1);
			if (endPosition.X > textBox.Width)
			{
				textBox.Focus();
				textBox.Select(textBox.Text.Length, 0);
				textBox.ScrollToCaret();
			}
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:20,代码来源:InterlinearSfmImportWizard.cs

示例12: ScrollToEnd

 /// <summary>
 /// Scrolls to end.
 /// </summary>
 /// <param name="tb">The tb.</param>
 public static void ScrollToEnd(TextBox tb)
 {
     tb.SelectionStart = tb.TextLength;
     tb.ScrollToCaret();
 }
开发者ID:andreigec,项目名称:ANDREICSLIB,代码行数:9,代码来源:TextboxExtras.cs

示例13: ScrollToBottom

 private void ScrollToBottom(TextBox txtBox)
 {
     txtBox.SelectionStart = txtBox.Text.Length - 1;
     txtBox.SelectionLength = 1;
     txtBox.ScrollToCaret();
 }
开发者ID:ScruffyKnight,项目名称:PMU-Server,代码行数:6,代码来源:MainUI.cs

示例14: AddRecievedData

        private void AddRecievedData(string data, TextBox textbox)
        {
            try
            {
                data = data.Replace("\n", "\r\n");

                textbox.AppendText(data);
                //textbox.Text += data;
                textbox.SelectionStart = textbox.Text.Length;
                textbox.ScrollToCaret();
            }
            catch (Exception ex)
            {
                Console.WriteLine("AddRecievedDataErroe:" + ex.Message);
            }
        }
开发者ID:nyanp,项目名称:Nano-Term,代码行数:16,代码来源:MainForm.cs

示例15: SetLog

 /// <summary>
 /// Hiển thị Log lên textbox
 /// </summary>
 /// <param name="txt"></param>
 /// <param name="text"></param>
 private void SetLog(TextBox txt, object text)
 {
     if (txt != null && text != null)
     {
         Invoke((MethodInvoker)delegate
         {
             txt.Text += text + Environment.NewLine;
             txt.SelectionStart = txt.Text.Length;
             txt.ScrollToCaret();
         });
     }
 }
开发者ID:votienphat,项目名称:ChuKySo,代码行数:17,代码来源:Form1.cs


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