本文整理汇总了C#中System.Windows.Forms.TextBoxBase.DeselectAll方法的典型用法代码示例。如果您正苦于以下问题:C# TextBoxBase.DeselectAll方法的具体用法?C# TextBoxBase.DeselectAll怎么用?C# TextBoxBase.DeselectAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TextBoxBase
的用法示例。
在下文中一共展示了TextBoxBase.DeselectAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rx_TextBox_Valid
//Checks for valid input for Rx textboxes. Checks the box passed in through "tb, "
//using different criteria based on parameter the box represents (determined by "box").
//Checks for valid ranges, does not check for valid increments.
/// <summary>
/// Checks for valid input for an Rx textbox
/// </summary>
/// <param name="tb">The box to check the contents of</param>
/// <param name="box">The Rx parameter - Sphere, Cylinder, Axis or Add</param>
/// <returns>True if the contents are valid, false otherwise</returns>
/// <exception cref="System.FormatException">Thrown when the text is not a proper integer or real number</exception>
private bool Rx_TextBox_Valid(TextBoxBase tb, RxBox box)
{
int pos = tb.Text.LastIndexOf('.');
float val;
if(box == RxBox.Axis)
{
if(tb.TextLength == 0) //Blank
tb.Text = "0";
try { //Is the contents a valid integer?
val = Math.Abs(Convert.ToInt16(tb.Text));
}
catch {
return false;
}
tb.DeselectAll();
tb.Text = val.ToString("0");
//Checks for valid range
if(val > AXIS_MAX_VALUE) {
return false;
}
}
else //Sphere, Cylinder or Add
{
if(tb.TextLength == 0)
tb.Text = "0.00";
try { //Is the contents a valid real number?
val = Convert.ToSingle(tb.Text);
}
catch {
return false;
}
tb.DeselectAll();
if(pos > -1) //Handle decimal
{
string ts = tb.Text.Substring(pos + 1);
if(ts == "2" || ts == "7")
{
if(val < 0)
val -= 0.05F;
else
val += 0.05F;
}
}
if(box == RxBox.Cyl)
val = -Math.Abs(val);
tb.Text = val.ToString("0.00");
//Checks for valid range
if(box == RxBox.Sphere) {
if(val > SPHERE_MAX_VALUE) {
return false;
}
} else if(box == RxBox.Cyl) {
if(-val > CYLINDER_MAX_VALUE) {
return false;
}
} else {
if(val > ADD_MAX_VALUE) {
return false;
}
}
}
return true;
}