當前位置: 首頁>>代碼示例>>C#>>正文


C# TextBox.Select方法代碼示例

本文整理匯總了C#中System.Windows.Forms.TextBox.Select方法的典型用法代碼示例。如果您正苦於以下問題:C# TextBox.Select方法的具體用法?C# TextBox.Select怎麽用?C# TextBox.Select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.TextBox的用法示例。


在下文中一共展示了TextBox.Select方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DisplayChanges

        public static void DisplayChanges()
        {
            string changes = string.Empty;
            using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetManifestResourceNames().First(e => e.ToLower().Contains("changes.txt"))))
            {
                using (StreamReader sr = new StreamReader(s))
                {
                    changes = sr.ReadToEnd();
                }
            }

            Button b = new Button();
            b.Text = "Close";
            b.Dock = DockStyle.Bottom;
            b.Click += (src, evt) =>
            {
                ((Form)b.Parent).Close();
            };

            TextBox tb = new TextBox();
            tb.Text = changes;
            tb.Dock = DockStyle.Fill;
            tb.ReadOnly = true;
            tb.Multiline = true;
            tb.Select(0, 0);
            tb.ScrollBars = ScrollBars.Both;
            tb.WordWrap = true;

            Form f = new Form();
            f.Size = new Size(400, 400);
            f.Text = "Changelog";
            f.Controls.Add(tb);
            f.Controls.Add(b);
            f.ShowDialog();
        }
開發者ID:Dissimilis,項目名稱:AzureLogViewer,代碼行數:35,代碼來源:Version.cs

示例2: btnAdd_Click

        private void btnAdd_Click(object sender, EventArgs e)
        {
            var win = new Form();

            var label = new Label {Text = "Node text (\f for format code):", AutoSize = true, Dock = DockStyle.Top};
            var button = new Button {Text = "Add", Dock = DockStyle.Right};
            var input = new TextBox {Dock = DockStyle.Bottom};

            button.Click += (o, args) =>
                                {
                                    var selection = treeView.SelectedNode;
                                    var addition = Regex.Replace(input.Text, @"(?<!\\)\\f", "\f");
                                    if(selection == null)
                                    {
                                        treeView.Nodes.Add(addition);
                                    }
                                    else
                                    {
                                        selection.Nodes.Add(addition);
                                    }
                                    win.Close();
                                };

            win.Controls.Add(input);
            win.Controls.Add(button);
            win.Controls.Add(label);
            win.AcceptButton = button;

            win.Width = 300;
            win.Height = 72;

            win.Text = "Add Node";
            win.ShowDialog();
            input.Select();
        }
開發者ID:NicholasVanSickle,項目名稱:C--Winforms-Dynamic-Tree-View,代碼行數:35,代碼來源:Form1.cs

示例3: Clipboard_Dialog

    private Clipboard_Dialog ()
    { Text = AppMain.AppName + " - Clipboard" ;
      StartPosition = FormStartPosition.CenterParent ;
      FormBorderStyle = FormBorderStyle.FixedDialog ;
      ClientSize =  new Size (400, 420) ;

      MaximizeBox = false ;
      MinimizeBox = false ;
      ControlBox = false ;
      ShowInTaskbar = false ;

      Edit = new TextBox () ;

      Edit.Parent = this ;
      Edit.Multiline = true ;
      Edit.WordWrap = true ;
      Edit.ScrollBars = ScrollBars.Both ;
      Edit.Location = new Point (10, 10) ;
      Edit.Size = new Size (380, 340) ;
      Edit.Text = Clipboard.GetText () ;
      Edit.Select (0,0) ;

      Button Apply = new Button () ;

      Apply.Parent = this ;
      Apply.Location = new Point (50, 360) ;
      Apply.Size = new Size (70, 20) ;
      Apply.Text = "Apply" ;
	    Apply.Click += new EventHandler (OnApply) ;

      new OKButton (this) ;
    }
開發者ID:kcb146,項目名稱:editor,代碼行數:32,代碼來源:Clipboard_Dialog.CS

示例4: ShowTextDialog

        public static string ShowTextDialog(string caption)
        {
            var prompt = new Form()
            {
                FormBorderStyle = FormBorderStyle.FixedDialog,
                MinimizeBox = false,
                MaximizeBox = false,
                Width = 200,
                Height = 110,
                Text = caption,
                StartPosition = FormStartPosition.CenterScreen,
            };

            var cancel = new Button();
            cancel.Click += (sender, e) => prompt.Close();
            prompt.CancelButton = cancel;

            var textBox = new TextBox() { Left = 20, Top = 20, Width = 160, Height = 80, Text = "" };
            var confirmation = new Button() { Text = "Ok", Left = 50, Top = 50, Width = 100, DialogResult = DialogResult.OK };
            confirmation.Click += (sender, e) => { prompt.Close(); };

            prompt.Controls.Add(textBox);
            prompt.Controls.Add(confirmation);
            prompt.AcceptButton = confirmation;

            textBox.Select(0, textBox.Text.Length);

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                return textBox.Text;
            }
            return null;
        }
開發者ID:oswellchan,項目名稱:PowerPointLabs,代碼行數:33,代碼來源:DrawingsLabDialogs.cs

示例5: Search

 private static bool Search(String search, TextBox target, bool forward)
 {
     if (forward)
     {
         int start = target.SelectionStart + target.SelectionLength;
         int i = target.Text.IndexOf(search, start, StringComparison.InvariantCultureIgnoreCase);
         if (i >= 0)
         {
             target.Select(i, search.Length);
             return true;
         }
         else
         {
             i = target.Text.IndexOf(search, 0, StringComparison.InvariantCultureIgnoreCase);
             if (i >= 0)
             {
                 target.Select(i, search.Length);
                 return true;
             }
             else
                 return false;
         }
     }
     else
     {
         int start = target.SelectionStart;
         int i = target.Text.LastIndexOf(search, start, start + 1, StringComparison.InvariantCultureIgnoreCase);
         if (i >= 0)
         {
             target.Select(i, search.Length);
             return true;
         }
         else
         {
             i = target.Text.LastIndexOf(search, target.Text.Length - 1, target.Text.Length - start, StringComparison.InvariantCultureIgnoreCase);
             if (i >= 0)
             {
                 target.Select(i, search.Length);
                 return true;
             }
             else
                 return false;
         }
     }
 }
開發者ID:mblaine,項目名稱:NbtViewer,代碼行數:45,代碼來源:Find.cs

示例6: ValidarPrecio

 bool ValidarPrecio(TextBox precio){
     try {
         Double pre = Convert.ToDouble(precio.Text);
         return true;
     } catch {
         precio.Text = "0.0";
         precio.Select(0, precio.Text.Length);
         return false;
     }
 }
開發者ID:fenrrid,項目名稱:ProgramVisual,代碼行數:10,代碼來源:Form2.cs

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

示例8: FindNext

 void FindNext(TextBox X,TextBox Y)
 {
     int vtbd = X.Text.IndexOf(X.SelectedText);
     //string chuoicl = "";
     //if(vtbd-Y.TextLength>0)
     string     chuoicl = X.Text.Remove(0, vtbd+ Y.TextLength);
     vtbd += chuoicl.IndexOf(Y.Text) + Y.TextLength;
     X.Select(vtbd, Y.TextLength);
     X.Focus();
 }
開發者ID:WilliamSmart,項目名稱:AAAA,代碼行數:10,代碼來源:Form1.cs

示例9: create_TextBox

 public static TextBox create_TextBox(string message)
 {
     var textBox = new TextBox();
     textBox.Multiline = true;
     textBox.WordWrap = false;
     textBox.ScrollBars = ScrollBars.Both;
     textBox.ReadOnly = true;
     textBox.Text = message;
     textBox.Select(0, 0);
     return textBox;
 }
開發者ID:SiGhTfOrbACQ,項目名稱:O2.FluentSharp,代碼行數:11,代碼來源:Ex_Windows_Forms.cs

示例10: RequiresWindow

		private void RequiresWindow()
		{
			_window = new Form();
			var box = new TextBox();
			box.Dock = DockStyle.Fill;
			_window.Controls.Add(box);

			_window.Show();
			box.Select();
			Application.DoEvents();
		}
開發者ID:JohnThomson,項目名稱:libpalaso,代碼行數:11,代碼來源:WindowsKeyboardControllerTests.cs

示例11: createStepWithTextBox

    	public static IStep createStepWithTextBox(string stepTitle, string message)
    	{
			var textBox = new TextBox();
            textBox.Multiline = true;
            textBox.ScrollBars = ScrollBars.Vertical;
            textBox.ReadOnly = true;
            textBox.Text = message;
            textBox.Select(0, 0);	
            var newStep = new TemplateStep(textBox, 10, stepTitle);
            return newStep;
    	}
開發者ID:pusp,項目名稱:o2platform,代碼行數:11,代碼來源:MerlinWizard_ExtensionMethods_2.cs

示例12: TextBoxParaDecimal

 private decimal TextBoxParaDecimal(TextBox txt)
 {
     try
     {
         return Convert.ToDecimal(txt.Text);
     }
     catch
     {
         txt.Focus();
         txt.Select();
         throw new Exception("Número incorreto");
     }
 }
開發者ID:tca85,項目名稱:ASP.NET,代碼行數:13,代碼來源:Form1.cs

示例13: TextBoxParaInteiro

 private int TextBoxParaInteiro(TextBox txt)
 {
     try
     {
         return Convert.ToInt32(txt.Text);
     }
     catch
     {
         txt.Focus();
         txt.Select();
         throw new Exception   ("Número incorreto");
     }
 }
開發者ID:tca85,項目名稱:ASP.NET,代碼行數:13,代碼來源:Form1.cs

示例14: TextBoxParaData

 private DateTime TextBoxParaData(TextBox txt)
 {
     try
     {
         return Convert.ToDateTime(txt.Text);
     }
     catch 
     {
         txt.Focus();
         txt.Select();
         throw new Exception ("Data inválida!");
     }
 }
開發者ID:tca85,項目名稱:ASP.NET,代碼行數:13,代碼來源:Form1.cs

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


注:本文中的System.Windows.Forms.TextBox.Select方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。