本文整理汇总了C#中System.Windows.Forms.TextBox.SelectAll方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.SelectAll方法的具体用法?C# TextBox.SelectAll怎么用?C# TextBox.SelectAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TextBox
的用法示例。
在下文中一共展示了TextBox.SelectAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRecord
protected override void ProcessRecord()
{
var files = Directory.GetFiles(SessionState.Path.CurrentLocation.Path, SearchPattern);
if (files.Length > 0)
{
StringBuilder builder = new StringBuilder();
foreach (var file in files)
{
builder.AppendLine(file);
}
TextBox clipStore = new TextBox();
clipStore.Text = builder.ToString();
clipStore.Multiline = true;
clipStore.SelectAll();
clipStore.Copy();
WriteObject(string.Format("({0}) files copied.", files.Length));
}
else
{
WriteError(new ErrorRecord(new NullReferenceException("No Files to copy"), "0301", ErrorCategory.InvalidArgument, files));
}
}
示例2: NextFocus
public static void NextFocus(TextBox tb, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter && !bEnter)
{
bEnter = true;
tb.Focus();
tb.SelectAll();
}
}
示例3: CheckAndParseValue
private bool CheckAndParseValue(TextBox textBox, out int value)
{
if (int.TryParse(textBox.Text, out value))
return true;
MessageBox.Show(this, "Invalid numeric format!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox.SelectAll();
textBox.Focus();
return false;
}
示例4: CheckNumTextBox
/// <summary>
/// 檢查文本框的內容是否輸入正確
/// </summary>
/// <param name="target"></param>
/// <param name="textType"></param>
/// <returns></returns>
public static bool CheckNumTextBox(TextBox target, enmTextBoxValueType textType, enmNumCheckType checkType)
{
switch (textType)
{
case enmTextBoxValueType.enmInt:
int intValue = 0;
if(!int.TryParse(target.Text,out intValue))
{
target.SelectAll();
target.Focus();
return false;
}
if (checkType == enmNumCheckType.enmNotAllowZero && intValue == 0)
{
target.SelectAll();
target.Focus();
return false;
}
break;
case enmTextBoxValueType.enmDecimal:
decimal decValue = 0;
if (!decimal.TryParse(target.Text, out decValue))
{
target.SelectAll();
target.Focus();
return false;
}
if (checkType == enmNumCheckType.enmNotAllowZero && decValue == 0)
{
target.SelectAll();
target.Focus();
return false;
}
break;
}
return true;
}
示例5: IsEqualTo
public static bool IsEqualTo(TextBox txt1, TextBox txt2)
{
if (txt1.Text == txt2.Text)
{
return true;
}
MessageBox.Show("Passwords must be equal.");
txt1.Focus();
txt1.SelectAll();
return false;
}
示例6: EhDecimal
//Criar um método para converter em decimal
private decimal EhDecimal(TextBox txt)
{
try
{
return Convert.ToDecimal(txt.Text);
}
catch
{
txt.Focus();
txt.SelectAll();
throw new Exception("Informe apenas números");
}
}
示例7: EhShort
public static short EhShort(TextBox txt)
{
try
{
return Convert.ToInt16(txt.Text);
}
catch (Exception)
{
txt.Focus();
txt.SelectAll();
throw new Exception("Informe um ano válido");
}
}
示例8: CreateTextBox
private void CreateTextBox(LinkLabel label)
{
text = new TextBox();
text.Text = label.Text;
text.Location = label.Location;
text.Size = label.Size;
text.BorderStyle = BorderStyle.FixedSingle;
text.BackColor = Color.CornflowerBlue;
mainPanel.Controls.Add(text);
text.BringToFront();
text.KeyPress += new KeyPressEventHandler(text_KeyPress);
text.Focus();
text.SelectAll();
}
示例9: TahVazio
public static string TahVazio(TextBox txt)
{
if (txt.Text.Trim() != "")
{
return txt.Text;
}
else
{
txt.Focus();
txt.SelectAll();
throw new Exception("Preencha "
+ txt.Name.Substring(0, txt.Name.Length-7));
}
}
示例10: CheckAndParseValue
private bool CheckAndParseValue(TextBox textBox, out string value)
{
if (!string.IsNullOrWhiteSpace(textBox.Text))
{
value = textBox.Text.Trim();
return true;
}
MessageBox.Show(this, "Invalid name!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox.SelectAll();
textBox.Focus();
value = null;
return false;
}
示例11: EstaVazio
public static string EstaVazio(TextBox txt)
{
if (txt.Text.Trim() != "")
{
return txt.Text;
}
else
{
txt.Focus();
txt.SelectAll();
throw new Exception("Preencha o (a): " + txt.Name.Substring(3));
//substring é igual ao mid do VB. Dessa forma, estou especificando para pegar o texto
//que está depois do txt dos nomes que eu especifico. ex: txtNome, txtModelo
//se meu padrão de nomes fosse nomeTextBox usaria: txt.Name.Substring(0, txtName.Length - 7));
}
}
示例12: IsInt
public static bool IsInt(TextBox textBox)
{
if (IsPresent(textBox))
{
try
{
Convert.ToInt32(textBox.Text);
return true;
}
catch (FormatException)
{
MessageBox.Show(string.Format("{0} must be an integer number.", textBox.Tag), Title);
textBox.Focus();
textBox.SelectAll();
}
}
return false;
}
示例13: ValidarCPF
public void ValidarCPF(TextBox txt, Label lbl)
{
int soma = 0;
string dv = "";
if (txt.Text.Length != 11)
{
lbl.BackColor = Color.Orange;
lbl.ForeColor = Color.Red;
lbl.Text = "I N C O N S I S T E N T E";
}
else
{
//1º DV
for (int i = 8; i >= 0; i--)
{
soma += Convert.ToInt32(txt.Text.Substring(i, 1)) * (i + 1);
}
dv = Convert.ToString(soma % 11 % 10);
//2º DV
soma = 0;
for (int i = 9; i >= 1; i--)
{
soma += Convert.ToInt32(txt.Text.Substring(i, 1)) * i;
}
dv += Convert.ToString(soma % 11 % 10);
if (dv == txt.Text.Substring(9, 2))
{
lbl.BackColor = Color.Green;
lbl.ForeColor = Color.Yellow;
lbl.Text = "V Á L I D O";
}
else
{
lbl.BackColor = Color.Red;
lbl.ForeColor = Color.White;
lbl.Text = "N Ã O V Á L I D O";
}
txt.Focus();
txt.SelectAll();
}
}
示例14: IsEmail
public static bool IsEmail(TextBox textBox)
{
if (IsPresent(textBox))
{
try
{
MailAddress address = new MailAddress(textBox.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " [email protected]");
textBox.Focus();
textBox.SelectAll();
return false;
}
return true;
}
return false;
}
示例15: InputBox
/// <summary>
/// 输入对话框
/// </summary>
/// <param name="caption">标题</param>
/// <param name="hint">提示内容</param>
/// <param name="Default">默认值</param>
/// <returns></returns>
public static string InputBox(string caption, string hint, string Default)
{
Form inputForm = new Form
{
MinimizeBox = false,
MaximizeBox = false,
StartPosition = FormStartPosition.CenterScreen,
Width = 220,
Height = 150,
Text = caption
};
Label lbl = new Label { Text = hint, Left = 10, Top = 20, Parent = inputForm, AutoSize = true };
TextBox tb = new TextBox { Left = 30, Top = 45, Width = 160, Parent = inputForm, Text = Default };
tb.SelectAll();
Button btnok = new Button { Left = 30, Top = 80, Parent = inputForm, Text = "确定" };
inputForm.AcceptButton = btnok;//回车响应
btnok.DialogResult = DialogResult.OK;
Button btncancal = new Button
{
Left = 120,
Top = 80,
Parent = inputForm,
Text = "取消",
DialogResult = DialogResult.Cancel
};
try
{
return inputForm.ShowDialog() == DialogResult.OK ? tb.Text : null;
}
finally
{
inputForm.Dispose();
}
}