本文整理匯總了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();
}
示例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();
}
示例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) ;
}
示例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;
}
示例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;
}
}
}
示例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;
}
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例12: TextBoxParaDecimal
private decimal TextBoxParaDecimal(TextBox txt)
{
try
{
return Convert.ToDecimal(txt.Text);
}
catch
{
txt.Focus();
txt.Select();
throw new Exception("Número incorreto");
}
}
示例13: TextBoxParaInteiro
private int TextBoxParaInteiro(TextBox txt)
{
try
{
return Convert.ToInt32(txt.Text);
}
catch
{
txt.Focus();
txt.Select();
throw new Exception ("Número incorreto");
}
}
示例14: TextBoxParaData
private DateTime TextBoxParaData(TextBox txt)
{
try
{
return Convert.ToDateTime(txt.Text);
}
catch
{
txt.Focus();
txt.Select();
throw new Exception ("Data inválida!");
}
}
示例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();
}
}