本文整理汇总了C#中System.Windows.Forms.MaskedTextBox.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# MaskedTextBox.Focus方法的具体用法?C# MaskedTextBox.Focus怎么用?C# MaskedTextBox.Focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.MaskedTextBox
的用法示例。
在下文中一共展示了MaskedTextBox.Focus方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidarTelefono
//Para Verificar que los Telefonos,Celulares,Fax estan llenado de Forma Correcta
public static bool ValidarTelefono(MaskedTextBox Txt)
{
bool flag;
Txt.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
if (Txt.Text.Length != 0 && Txt.MaskFull == false)
{
flag = false;
Txt.Focus();
}
else
{
flag = true;
}
return flag;
}
示例2: LoadControls
/// <summary>
/// Loads controls on the panel
/// </summary>
private void LoadControls()
{
foreach (SearchListBoxItem item in searchFieldsCollection)
{
//add masked textbox or textbox to the panel
if (!string.IsNullOrEmpty(item.Pattern))
{
//Add masked textbox to the panel
MaskedTextBox fieldTextBox = new MaskedTextBox();
fieldTextBox.Location = new System.Drawing.Point(300, textLinePosition);
fieldTextBox.Size = new System.Drawing.Size(286, 20);
fieldTextBox.BringToFront();
fieldTextBox.Leave += new EventHandler(fieldTextBox_Leave);
// fieldTextBox.MaskInputRejected += new MaskInputRejectedEventHandler(maskedTextBox_MaskInputRejected);
string mask = AppData.Instance.DataPatternsDataTable.GetMaskByPattern(item.Pattern);
//fieldTextBox.Mask = AppData.Instance.DataPatternsDataTable.GetExpressionByMask(mask, item.Pattern);
fieldTextBox.Tag = item.Type;
fieldTextBox.Name = item.Name;
//fieldTextBox.Mask = mask;
if (item.Type.Equals("Number") || item.Type.Equals("PhoneNumber"))
{
// fieldTextBox.PromptChar = '_';
}
else if (item.Type.Equals("Date") || item.Type.Equals("DateTime"))
{
// fieldTextBox.PromptChar = '_';
fieldTextBox.Text = String.Format("{0}", string.Empty);
}
else if (item.Type.Equals("Time"))
{
// fieldTextBox.PromptChar = '_';
fieldTextBox.Text = String.Format("{0:T}", string.Empty);
}
splitContainer1.Panel2.Controls.Add(fieldTextBox);
textLinePosition += 38;
if (myControlDictionaryData.ContainsKey(item.Name.ToString()))
{
fieldTextBox.Text = myControlDictionaryData[item.Name.ToString()].ToString();
}
myControlDictionary.Add(item.Name.ToString(), fieldTextBox);
myControlItemDictionary.Add(fieldTextBox, item);
fieldTextBox.Focus();
}
else
{
//if (item.Type.Equals("YesNo"))
//{
// ComboBox cbxYesNo = new ComboBox();
// Configuration config = Configuration.GetNewInstance();
// cbxYesNo.Items.AddRange(new object[] { config.Settings.RepresentationOfYes, config.Settings.RepresentationOfNo, config.Settings.RepresentationOfMissing });
// cbxYesNo.Location = new System.Drawing.Point(300, textLinePosition);
// cbxYesNo.Size = new System.Drawing.Size(286, 20);
// cbxYesNo.BringToFront();
// cbxYesNo.Leave += new EventHandler(fieldTextBox_Leave);
// splitContainer1.Panel2.Controls.Add(cbxYesNo);
// textLinePosition += 38;
// myControlDictionary.Add(item.Name.ToString(), cbxYesNo);
// myControlItemDictionary.Add(cbxYesNo, item);
// cbxYesNo.Focus();
//}
//else
{
////add textbox to panel
TextBox fieldTextBox = new TextBox();
fieldTextBox.Name = item.Name;
fieldTextBox.Location = new System.Drawing.Point(300, textLinePosition);
fieldTextBox.Size = new System.Drawing.Size(286, 20);
fieldTextBox.BringToFront();
fieldTextBox.Leave += new EventHandler(fieldTextBox_Leave);
splitContainer1.Panel2.Controls.Add(fieldTextBox);
textLinePosition += 38;
myControlDictionary.Add(item.Name.ToString(), fieldTextBox);
myControlItemDictionary.Add(fieldTextBox, item);
fieldTextBox.Focus();
}
}
//add field name label to panel
Label fieldName = new Label();
fieldName.Tag = item.Name.ToString().ToUpper();
fieldName.Location = new System.Drawing.Point(26, labelLinePosition);
fieldName.Size = new System.Drawing.Size(35, 13);
fieldName.AutoSize = true;
fieldName.FlatStyle = FlatStyle.System;
fieldName.Text = item.Name.ToString();
splitContainer1.Panel2.Controls.Add(fieldName);
labelLinePosition += 38;
//add pattern label to panel
Label lblPattern = new Label();
//.........这里部分代码省略.........
示例3: IsPhoneNumber
/// <summary>
/// Checks to see if the text box contains a phone number.
/// </summary>
/// <param name="textBox">The text box control</param>
/// <returns>True IFF the text box contrains a phone number</returns>
public static bool IsPhoneNumber(MaskedTextBox textBox)
{
string phoneChars = textBox.Text.Replace(".", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace(" ", "");
try
{
Convert.ToInt64(phoneChars);
return true;
}
catch (FormatException)
{
MessageBox.Show(textBox.Tag.ToString() + " must be in this format: 999-999-9999", Title);
textBox.Focus();
return false;
}
}
示例4: IsStateZipCode
/// <summary>
/// Checks to see if the text box contains a zip code.
/// </summary>
/// <param name="textBox">The text box control</param>
/// <param name="firstZip">The lowest numerical zip code</param>
/// <param name="lastZip">The highest numerical zip code</param>
/// <returns>True IFF the text box contrains a zip code</returns>
public static bool IsStateZipCode(MaskedTextBox textBox, int firstZip, int lastZip)
{
//00501
//99950
int zipCode = Convert.ToInt32(textBox.Text);
if (zipCode < firstZip || zipCode > lastZip)
{
MessageBox.Show(textBox.Tag.ToString() + " must be within this range: " +
firstZip.ToString("D5") + " to " + lastZip.ToString("D5") + ".", Title);
textBox.Focus();
return false;
}
else
{
return true;
}
}
示例5: continuidade
public void continuidade(MaskedTextBox usado, MaskedTextBox texto1, MaskedTextBox texto2)
{
if (podeCodigo(Convert.ToInt16(usado.Text)))
{
if (texto1.Visible)
{
if (texto1.Text.Length>0 && podeCodigo(Convert.ToInt16(texto1.Text)))
{
if (texto2.Visible)
{
if (texto2.Text.Length > 0 && podeCodigo(Convert.ToInt16(texto2.Text)))
{
preencherLabelDescritivo(new Banco().codTamanho(cbTamanho.Text)
, new Banco().codDivisorByDescricao(cbMista.Text));
gbQtd.Visible = true;
gbQtd.Focus();
}
else { texto2.Clear(); texto2.Focus(); }
}
else
{
preencherLabelDescritivo(new Banco().codTamanho(cbTamanho.Text)
, new Banco().codDivisorByDescricao(cbMista.Text));
gbQtd.Visible = true;
gbQtd.Focus();
}
}
else { texto1.Clear(); texto1.Focus(); }
}
else
{
preencherLabelDescritivo(new Banco().codTamanho(cbTamanho.Text)
, new Banco().codDivisorByDescricao(cbMista.Text));
gbQtd.Visible = true;
gbQtd.Focus();
}
}
else { usado.Clear(); usado.Focus(); }
}
示例6: Password
/// <summary>
/// force means ignore any cache and require the user to enter a password
/// </summary>
/// <param name="prompt"></param>
/// <param name="force"></param>
/// <returns></returns>
public static string Password(string prompt, bool requireEntry)
{
string passwordFileName;
if (!string.IsNullOrWhiteSpace(prompt))
{
if (ProcessFunctions.KeplerProcess != null)
{
passwordFileName = SwishFunctions.GeneratePasswordFileName(prompt, ProcessFunctions.KeplerProcess);
passwordFileName = Path.Combine(Path.GetTempPath(), passwordFileName);
if (!requireEntry && FileFunctions.FileExists(passwordFileName))
{
string _encodedPassword = File.ReadAllText(passwordFileName);
string _password = SwishFunctions.DecodePassword(_encodedPassword, ProcessFunctions.KeplerProcess);
return _password;
}
} else
{
passwordFileName = string.Empty;
}
} else
{
prompt = "Please enter password";
passwordFileName = string.Empty;
}
string password;
using (MaskedTextBox textBox = new MaskedTextBox())
using (Panel panel = new Panel())
using (Button buton = new Button())
using (Form form = new Form())
{
textBox.SuspendLayout();
buton.SuspendLayout();
panel.SuspendLayout();
form.SuspendLayout();
textBox.UseSystemPasswordChar = true;
textBox.Multiline = true;
textBox.SelectionStart = 0;
textBox.SelectionLength = 0;
textBox.Size = new Size(300, textBox.Height);
textBox.Dock = DockStyle.Top;
textBox.Font = new Font(textBox.Font, FontStyle.Bold);
textBox.TabIndex = 0;
buton.Click += new EventHandler(buton_Click);
buton.Dock = DockStyle.Left;
buton.Text = "Ok";
buton.Size = new Size(75, 23);
buton.TabIndex = 0;
panel.Height = 23;
panel.Controls.Add(buton);
panel.Dock = DockStyle.Fill;
panel.TabIndex = 1;
form.ControlBox = false;
form.Text = prompt;
form.ClientSize = new Size(300, 43);
form.Controls.Add(panel);
form.Controls.Add(textBox);
form.AcceptButton = buton;
textBox.ResumeLayout();
buton.ResumeLayout();
panel.ResumeLayout();
form.ResumeLayout();
textBox.Focus();
form.ShowDialog();
password = textBox.Text;
}
if (string.IsNullOrWhiteSpace(password))
{
return string.Empty;
}
if (string.IsNullOrWhiteSpace(passwordFileName))
{
return password;
}
string encodedPassword = SwishFunctions.EncodePassword(password, ProcessFunctions.KeplerProcess);
if (File.Exists(passwordFileName))
{
FileFunctions.DeleteFile(passwordFileName, null);
}
File.WriteAllText(passwordFileName, encodedPassword);
return password;
//.........这里部分代码省略.........
示例7: ValidarTelefono
//Para Verificar que los Telefonos,Celulares,Fax estan llenado de Forma Correcta
public void ValidarTelefono(MaskedTextBox Txt, string mensaje)
{
Txt.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
if (Txt.Text.Length != 0 && Txt.MaskFull == false)
{
ErrPro.SetError(Txt, mensaje);
Txt.Focus();
}
else
{
ErrPro.SetError(Txt, null);
}
}