zoukankan      html  css  js  c++  java
  • 查找 TextBox 对象中非法数据的示例

    1. private void GetErrors(StringBuilder sb, DependencyObject obj){  
    2.             foreach (object child in LogicalTreeHelper.GetChildren(obj)){  
    3.                 TextBox element = child as TextBox;  
    4.                 if (element == null)   
    5.                     continue;  
    6.                 if (Validation.GetHasError(element)){  
    7.                     sb.Append(element.Text + " has errors: ");  
    8.                     foreach (ValidationError error in Validation.GetErrors(element)){  
    9.                         sb.Append(" " + error.ErrorContent.ToString());  
    10.                         sb.Append(" ");  
    11.                     }  
    12.                 }  
    13.             }  
    14.         }  
    15.   
    16.         private bool FromHasErrors(out string message){  
    17.             StringBuilder sb = new StringBuilder();  
    18.             GetErrors(sb, stackProductDetails);  
    19.             message = sb.ToString();  
    20.             return message != "";  
    21.         }  
    22.   
    23.         private void cmdOK_Click(object sender, RoutedEventArgs e){  
    24.             string message;  
    25.             if (FromHasErrors(out message)){  
    26.                 MessageBox.Show(message);  
    27.             }  
    28.             else{  
    29.                 // ...  
    30.             }  
    31.         }  
    32.     }  

     http://blog.csdn.net/iHuoBaby/article/details/8576165

  • 相关阅读:
    Codeforces Gym
    洛谷试炼场一句话题解
    优先队列板子
    BZOJ 3524 [POI2014] Couriers/洛谷3567(可持久化线段树)
    hdu 4417 Super Mario(可持久化线段树)
    poj 2559 Largest Rectangle in a Histogram (单调栈)
    zoj 4019 Schrödinger's Knapsack
    hdu 1521 排列组合(指数型生成函数板子)
    hdu 2072 单词数(普通型生成函数板子)
    RabbitMQ广播:direct模式
  • 原文地址:https://www.cnblogs.com/sjqq/p/8059233.html
Copyright © 2011-2022 走看看